DatagramSocket SetSoTimeout() Example
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
DatagramSocketclass SetSoTimeout() method example. This example shows you how to use SetSoTimeout() method.This method Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
Here is the code:-
/**
* @Program that Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
* SetSoTimeout.java
* Author:-RoseIndia Team
* Date:-20-jun-2008
*/
import java.net.*;
public class SetSoTimeout {
public static void main(String[] args) throws Exception {
DatagramSocket ds = new DatagramSocket();
ds.connect(new InetSocketAddress(9090));
System.out.println("Setting for SO_TIMEOUT is: " + ds.getSoTimeout());
//Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
ds.setSoTimeout(23);
System.out.println("Setting for SO_TIMEOUT is: " + ds.getSoTimeout());
}
} |
Output of the program:-
Setting for SO_TIMEOUT is: 0
Setting for SO_TIMEOUT is: 23 |
|