All pastes #518989 Raw Edit

Untitled

public text v1 · immutable
#518989 ·published 2007-05-29 14:29 UTC
rendered paste body
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());
	}
}