1、udpclient(Linux)
1 /*UDP client*/ 2 DatagramSocket ss; 3 ss.connect(SocketAddress("192.168.20.43", 6000)); 4 int n = ss.sendBytes("hello", 5);//发送 5 char buffer[256]; 6 n = ss.receiveBytes(buffer, sizeof(buffer));//udp client接收 7 printf("n = %d\n",n);
2、udpserver(win7)
1 /*UDP server*/ 2 UDPEchoServer echoserver(SocketAddress("192.168.20.43",6000)); 3 echoserver.run();