DatagramSocket Client : UDP « Network Protocol « Java

DatagramSocket Client


class WriteServer {
  public static void main(String args[]) throws Exception {
    int clientPort = 999;

    int buffer_size = 1024;

    byte buffer[] = new byte[buffer_size];
    DatagramSocket ds = new DatagramSocket(clientPort);
    while (true) {
      DatagramPacket p = new DatagramPacket(buffer, buffer.length);
      System.out.println(new String(p.getData(), 0, p.getLength()));


Related examples in the same category

1.Udp Echo Server
2.DatagramSocket Server
3.Send out UDP pockets
4.Receive UDP pocketsReceive UDP pockets
5.Experiment with UDP sockets
6.Using Datagrams to Get the Date
7.An echo server using UDP socketsAn echo server using UDP sockets
8.Connect to a daytime server using the UDP protocol
9.Handles TCP and UDP connections and provides exception handling and error logging
10.UDP OutputStream
11.UDP InputStream
12.Performs broadcast and multicast peer detection.