c++ - UDP network stuck while system waiting/receiving data -


i have build bilateral udp network system, means both server , client send , receive data, illustrated below diagram:

network diagram

i took ready use example http://www.binarytides.com/udp-socket-programming-in-winsock/

however, on client, when data(string) sent, client gets stuck waiting incoming data on line: recvfrom(s, buf, buflen, 0, (struct sockaddr *) &si_other, &slen)

the client cannot send more data until receives incoming data.

is there method can keep sending data server, while waiting incoming data?

this because default sockets blocking, means recv , read family calls hang until there data available. need either use nonblocking i/o multiplexing select() or poll(), or use separate, dedicated thread receiving data.

nonblocking i/o different in design blocking i/o code, there's not simple change can make. recommend read beej's guide network programming covers of these issues.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -