Multithreaded server, where to start?
Hi all,
I've written a pretty basic server. However now I've ran into a problem (and well I'm on an extremely short deadline so hopefully you guys can help me out).
Basically, I can connect with one client. However because accept blocks and I am waiting for other connections I only recieve data once. Can someone, hell even psuedo code will be awesome, can just show me an example (if you could help with select() example that'd be sweet) of how I can accept multiple connections and still recieve data.
I just don't have a clue about threads, well I do, but only theory, never used them. And so I have about another 5 hours of fumbling around with my code searching the web for examples and tutorials before I'm screwed well and truely..
Thanks in advance, and even if it's not in time I'd definitely like to know how to complete this.
[edit:] I'm not sure if it helps, code usually does I guess.. But this is what I'm doing in the server at the moment-
Code:
while(1){
if(listen(this->listen_socket, 10) != SOCKET_ERROR){
this->acceptconnection();
this->recievedata();
cout << "Connection accepted" << endl;
}else{
cout << "SOCKET_ERROR on listen_socket" << endl;
}
}
[edit2:]Geez that formatting screwed up royally
[edit again:] Also, have I got listen() in the wrong place there? I don't need it in the loop do I? I've been going for nearly 24 hours straight without barely any knowledge of winsock so sorry if that was a really stupid question.