• Post Reply Bookmark Topic Watch Topic
  • New Topic

datagramSocket.receive always giving SocketTimeoutException

 
Muhammad Abubakar Afzal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can someone tell me why is this happening?
 
Henry Wong
author
Sheriff
Posts: 22639
111
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Basically, somewhere earlier in your code, you did a setSoTimeout() method call on that datagramSocket. This is done so that reads (ie. receive() calls) do not take forever.

And then, of course, when you call the receive() method, something is wrong. It doesn't get the datagram in the specified timeout, and hence, throws the exception.  Now, as for what the "something" that is wrong is, you will need to debug it -- it could be that the sender is not running (or didn't send it within the timeout), it could be the network, it could be a firewall, router, etc.

Henry
 
Campbell Ritchie
Marshal
Posts: 53207
124
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You would have to give us lots more details before we can help.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!