java udp socket

2008-02-23 10:12:59来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

i use Java udp socket write a program today.

classes used:
DatagramScocket(int port);
DatagramPacket(byte[] buf, int length, InetAddress address,int port); //for send
DatagramPacket(byte[] buf, int length); //for receive

implements:
first, construct a DatagramSocket object with a specified port.
then construct a DatagramPacket with a buffer, length, InetAddress and port to send you message,
the message is stroed in the buffer which is a byte array.

also you can construct a DatagramPacket with a buffer and length to recieve message from the port blinded with you socket.


note:
if you send message to a server that not recieve you message , the message is lost. this future is differnet to tcp connetion.
so to make udp program , you must deal with package lost!!!

上一篇: Mini Java编译器(一)——任务概述
下一篇: 用 Java 访问 Domino 的对象(四)

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:学习顺便翻译:理解jsp模式2架构——MVC设计模式探险

下一篇:Mini Java编译器(一)——任务概述