single Socket for listening and sending/receiving, Simultaneously?
Is it possible to use the same network Socket simultaneously, for listening (for incoming connections) and communicating with a non-connected client (using the sendto() and recvfrom() functions)? Or must I have two separate sockets, and if so must the separate sockets also be bound to separate network ports? Just for the info, I am using WinSock 2 API functions.
High thanks in advance :)
I think you need threads for this ...
I think threads would be the right solution. I made a two-person chat application not too long ago, that I haven't finished yet, and I had to use threads, to control both sending and receiving data. Try going to http://msdn.microsoft.com/library and searching for _beginthread() or _beginthreadex(). I just used a function called Server(), declared as 'void Server()', that accepted connections and listened for incoming data. For multi-connection support is jus a little more complicated, but not by means of threads. You just have to create an array of listening sockets. For example:
I don't know if this is EXACTLY what you need, but I think it should help you.
// These are global variables
SOCKET listening; // Where ten is the maximum number of sockets that can be connected at once