i have a program with two threads. Both of them use a Winsock2 udp socket to send data. Now it seems that on one of the pc's the sending thread is blocking the receiving thread. the two connections are running over different sockets and different ports. the two threads are sharing no data whatsoever. they run completly isolated from each other and are working fine when i run them seperately. i am really running out of ideas how this is possible.
now i can say for sure that the remote pc is still sending data. but my pc here stops receiving as soon as the second thread (sending data) starts to work. he hangs at the recv (winsock2) function. like it would be waiting for packages.
is it possible that the second thread just uses up all the bandwith ?
both threads use 1 message pump, so they both use WM_SOCKET. How do you split work? Do you know that winsock functions are not thread safe?
1 thread with pump ---on recieve-->push msg on queue
<-----------go back at set some receive event---
working threads should sleep (waitforsingleobject) until receive event is set. When it does wake up, it should pop msg from queue and process it. Key here is to put critical sections in pop and push functions to access queue.
yes i know that winsock is not thread safe. that's why i use two different sockets and ports for the two connections. maybe i was not clear enought: the two threads do NOT interact. they are running seperately. one is sending data, one is receiving other data.
now i get a WSAEINVAL error from the recvfrom function as soon as the second thread starts. the microsoft site says that happens when the socket is not bound. but it was bound before or it wouldnt work to begin with right ?