java udp sockect编程(转)
2011年03月01日
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 stored 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!!!
udp为不可靠传送,必须处理包丢失的问题
java udp socket 编程
2011年03月01日
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 stored 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!!!
udp为不可靠传送,必须处理包丢失的问题
java udp socket 编程
Java UDP Socket编程详解
本文详细介绍了Java UDP Socket编程的基本概念、使用方法及注意事项,强调了处理包丢失问题的重要性。
367

被折叠的 条评论
为什么被折叠?



