Winsock Programming Question
Posted on 2002-04-11
I'm having a little trouble figuring out how to handle something.
Ok, here's the situation:
1) The server must be able to handle multiple connections
possible solutions I have thought of are:
threaded, each new connection gets thrown into a
new thread (yuck)
Solution I would like, but have no clue how to implement:
Standard loop with rest of the program, as the server already performs other tasks, and could output as needed. During the loop, it would check for new connections, and send and receive data from existing connections.
2) The server can't wait for a connection, it needs to do its processing regardless, but must be able to accept a connection.
Although this is not a game that I am toying with, one could think of it as a simple game server, the game logic needs to process, updating clients, while waiting for new clients.
Kicker: I want to use both udp and tcp. udp for some clients, tcp for others - ie: player can be udp, packets are ok to loose, admin needs tcp to guarantee messages/responses.
I'm trying to find good, easy to follow information to help me complete my little program. I am writing both the client and the server.
This is NOT a school project, but rather my own attempt to learn and understand winsock to use in more important apps later. I am mostly looking just for a reference, good sites or books that could help me learn and understand.
(ps - sending me to udp sites for the daytime protocol won't cut it, been reading those left and right at about every site that talks about winsock programming their servers wait for clients and can only handle one client at a time)
Any help would be appreicated, I just can't seem to find quality info beyond how to write a daytime server and client.
Final note - NOT MFC, NOT JAVA. I would prefer C based solutions (as that is what I program in mostly now adays), although I would entertain C++ solutions if I could figure out how to implement them.
I realize that Unix sockets programming is similar, but I would prefer a Winsock based example as this app will require Windows.