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!!!