Code example for DatagramSocket

Methods: closedisconnectisConnected

0
	 */ 
	public void close() { 
		try { 
 
			// 关闭接收套接字 
			if (receiveSocket.isConnected()) {
				receiveSocket.disconnect();
				receiveSocket.close();
			} 
 
			// 关闭发送套接字 
			if (sendSocket.isConnected()) {
				sendSocket.disconnect();
				sendSocket.close();
			} 
		} catch (Exception ex) {
			ex.printStackTrace();
		} 
	} 
} 
Connect your IDE to all the code out there  Get Codota for Java