Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
UDP network stuck while system waiting/receiving data

I have to build up a bilateral UDP network system, that means both server and client send and receive data, as illustrated by the below diagram:

network diagram

I took a ready to use example from http://www.binarytides.com/udp-socket-programming-in-winsock/

However, on the client, when a data(string) is sent, the client gets stuck waiting for incoming data on this line: recvfrom(s, buf, BUFLEN, 0, (struct sockaddr *) &si_other, &slen)

The client cannot send more data until it receives incoming data.

Is there any method that I can keep sending data to the server, while also waiting for incoming data?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is because by default sockets are blocking, which means recv and read family calls will hang until there is data available. You need to either use nonblocking I/O with multiplexing like select() or poll(), or use a separate, dedicated thread for receiving data.

Nonblocking I/O is significantly different in design from blocking I/O code, so there's not a simple change you can make. I recommend you read something like Beej's Guide to Network Programming which covers all of these issues.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!