udp port failed, server cannot start
<pre><code>import java.io.*;
import java.net.*;

public class Server{

    public static void main(String[] args) throws SocketException, IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int myPort= 2002;           
        String name;
        String serverMsg;
        String clientMsg;
        byte[] dataReceive = new byte[65536];
        byte[] sendData = new byte[65536];

        DatagramPacket packetReceive = new DatagramPacket(dataReceive,dataReceive.length);
        DatagramPacket sendPacket= new DatagramPacket(sendData,sendData.length);
        DatagramSocket server= new DatagramSocket(myPort);
        serverMsg="Pls enter your name:";
        sendData=serverMsg.getBytes();
        sendPacket.setData(sendData);
        sendPacket.setAddress(packetReceive.getAddress());
        sendPacket.setPort(packetReceive.getPort());
        server.send(sendPacket);    
        server.receive(packetReceive);
        clientMsg = new String(packetReceive.getData(),0,packetReceive.getLength());
        serverMsg="yourname is "+clientMsg;
        sendData=serverMsg.getBytes();
        sendPacket.setData(sendData);
        sendPacket.setAddress(packetReceive.getAddress());
        sendPacket.setPort(packetReceive.getPort());
        server.send(sendPacket);

        server.close();
    }
}
</code></pre>

<hr>

<h2>General Output</h2>

<pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Port out of range:-1
    at java.net.DatagramPacket.setPort(DatagramPacket.java:292)
    at Server.main(Server.java:25)
</code></pre>
