• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

UDP programming

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a UDP client server pair that are supposed to communicate with each other by sending messages back and forth 1000 times. However, in my current program, it only does this once and then it hangs. My question is how can I modify UDPClient2.java and UDPServer2.java so that they can synchronize their communication for 1000 iterations.

Thanks a lot.

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember UDP is a stateless protocol, so if a packet is lost, it is lost.
You are assuming that the receive in the complementary program starts before the send in the other program.
If that does not happen then your packet is lost and your program hangs.

So after your send (whether sending the data or ack) you need to timeout after a certain time and then retry. And the timeouts in both the programs should be different based upon an initial shared key so both the programs do not time out at the same time.
 
straws are for suckers. tiny ads are for attractive people.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic