Code example for DatagramSocket

Methods: close, setReuseAddress

0
		ServerSocket ss = null;
		DatagramSocket ds = null;
		try { 
			ss = new ServerSocket(port);
			ss.setReuseAddress(true);
			ds = new DatagramSocket(port);
			ds.setReuseAddress(true);
			return true; 
		} catch (IOException e) {
		} finally { 
			if (ds != null) {
				ds.close();
			} 
 
			if (ss != null) {
				try { 
					ss.close();
				} catch (IOException e) {
					/* should not be thrown */ 
				} 
			}