java中请给出UDP的DatagramSocket通信的例子?

马克-to-win:在UDP编程当中,技术上没有一个服务器和客户端的概念,即没有类似于TCP中的ServerSocket类,只有主动和被动之说,客户端和服务器都用DatagramSocket(MyPORT)来绑定到一个端口,发送和接收dataPacket,它们是对等的双方。不过通常来讲,先发送数据的被认为是客户端。in UDP, there is no concept of server or client, onlyactive and passive, client and server both use newDatagramSocket(MyPORT) to bind to a port to use the port to send andreceive the dataPacket, the counterpart which initially send thedataPacket is deemed as the client.  unlike the TCP protocol, there,there is really ServerSocket.

UDP通信主要有两个类,DatagramPacket是数据容器,

详情黏贴以下网址在地址栏后请进:http://www.mark-to-win.com/JavaBeginner/JavaBeginner9_web.html#UDPSimplestExample

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页