`
xdq406at
  • 浏览: 18590 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

java udp sockect编程(转)

 
阅读更多

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 编程
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics