import java.net.*; public class ClientMain { public static void main(String[] args) throws Exception { byte[] buffer = new byte[100]; DatagramPacket inPack = new DatagramPacket(buffer, buffer.length); // Attempt to connect to the server. It doesn't connect per se like a TCP // connection, but instead let the server know who you are and hence you are // "listening". System.out.println("Connecting to Server..."); DatagramSocket ds = new DatagramSocket(); ds.send(new DatagramPacket("SUFTP 100 HELLO".getBytes(), "SUFTP 100 HELLO".length(), InetAddress.getByName("127.0.0.1"), 55500)); ds.receive(inPack); System.out.println(new String(inPack.getData()).trim()); } }