Multithreading Quesiton
I am writing a tiny chat program (console) as an exercise. - winsock 2 (WSA) - UDP - Non Blocking My program creates a second thread that generally sits in a blocking Recv (or RecvFrom) call, and processes the packets as they come. Now, in my program, I have a main loop, and I would like to send keystrokes to various clients... Is this allowed if my other thread is sitting on a recv call? (I.e. is winsock2 thread safe within itself?) I have another (unrelated) question about networking. You can bind to an address, but what if you have 2 network cards in the system? How do I bind to separate networks?
Winsock should be thread safe. At least I've never had a problem with it and our main app (non-game) is a service that opens many sockets on different threads.
Since you are using UDP, you don't need to deal with one socket like you would with TCP. Your main thread should be able to send the message to the clients without any problem.
Since you are using UDP, you don't need to deal with one socket like you would with TCP. Your main thread should be able to send the message to the clients without any problem.
- onebeer
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement