1、udpserver
1 UDPEchoServer echoserver(SocketAddress("localhost",6000)); 2 echoserver.run();
2、udpclient
1 UDPEchoServer echoServer; 2 DatagramSocket ss; 3 ss.connect(SocketAddress("localhost", echoServer.port()));//连接 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);