|
-
April 8th, 2011, 10:37 PM
#1
Winsock Theory Question
I've been working on learning about socket programming using the windows api and have a question about winsock. Ive made an application the spawns a thread and sits and listens for connections. Once an incoming connection as been accepted it spawns a new thread and transmits data back and forth between the server and the client, and ends the thread once the client finishes sending data. My question was if this is the correct way to do this. At first when I accepted multiple connections, it spiked the cpu extremely high because it sat in an endless loop waiting for messages, but then I found a way to limit how much cpu the thread could use so it didnt eat up cpu resources. How is it that real sockets accept so many clients. Even if you could limit each thread to only using 5% cpu, what if hundreds of connections occured at once, that would be over 100% of the cpu. Has anyone worked with sockets before and know the correct implementation for accepting a large amount of clients or know a resource that explains it? Sorry for the long post I just had a lot to include in the question. Any help would be greatly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|