Reputation: 85
I need to enable and disable the timeout of a UDP datagram socket in Java.
It is possible to set its timeout using sendTokenSock.setSoTimeout(10000);
.
But if I need to disable its timeout and keep it receiving infinitely in another state in the program, how can I do it?
Upvotes: 0
Views: 1021
Reputation: 8938
I take it that sendTokenSock
is a java.net.DatagramSocket
: sendTokenSock.setSoTimeout(0);
will set an infinite timeout as setSoTimeout
documentation for Java SE 7 explains:
The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout.
Upvotes: 1