Code example for DatagramSocket

Methods: getLocalPort

0
public class SendSize { 
    static final int bufferLength = 512;
    static final int packetLength = 256;
 
    public static void main(String[] args) throws Exception {
        DatagramSocket serverSocket = new DatagramSocket();
        new ServerThread(serverSocket).start();
        new ClientThread(serverSocket.getLocalPort()).start();
    } 
 
    static class ServerThread extends Thread {
        DatagramSocket server;
 
        ServerThread(DatagramSocket server) {
            this.server = server;
        } 
 
        public void run() { 
            try { 
                System.err.println("started server thread: " + server);
Connect your IDE to all the code out there  Get Codota for Java