标签:
1、
发送数据
public static void SendUDP(String _strIp, int _iPort, byte[] _bufSend) throws Exception { //DatagramSocket local = new DatagramSocket(_iPort); DatagramSocket local = new DatagramSocket(); InetAddress addrDest = InetAddress.getByName(_strIp); //addrDest.isReachable(5000); DatagramPacket sendPacket = new DatagramPacket(_bufSend, _bufSend.length, addrDest, _iPort); local.send(sendPacket); local.close(); }
DatagramSocket 构造函数,如果传入端口号的话 是本地使用的端口号。
标签:
原文地址:http://www.cnblogs.com/CodeSkill/p/4926376.html