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

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World