Code example for DatagramPacket

Methods: setData

0
	 * @param data 
	 *            消息 
	 * @throws IOException 
	 */ 
	public void send(byte[] data) throws IOException {
		DatagramPacket dp = new DatagramPacket(buffer, buffer.length,
				InetAddress.getByName(remoteHost), sendPort);
		dp.setData(data);
		sendSocket.send(dp);
	} 
 
	/** 
	 * 关闭UDP套接字 
	 *  
	 */ 
	public void close() { 
		try { 
 
			// 关闭接收套接字 
			if (receiveSocket.isConnected()) {
				receiveSocket.disconnect();