Code example for DatagramSocket

Methods: setBroadcastsetReuseAddresssetSoTimeout

0
 
	protected abstract int getInterfaceAddress(); 
 
	@Override 
	protected void PreRun() throws Exception { 
		socket = new DatagramSocket(getPort(), InetAddress.getByAddress(IP
				.IntToBytes(getInterfaceAddress()))); 
		socket.setBroadcast(true);
		socket.setReuseAddress(true);
		socket.setSoTimeout(100);
	} 
 
	@Override 
	protected void PostRun() throws Exception { 
		if (socket != null) {
			socket.close();
			socket = null;
		} 
	} 
 
	@Override