The following code returns -1.Please any body tell solution to solve and tell something about this uses of localport .
import java.net.*;
import java.io.*;
public class Test
{
public static void main(String[] args)
{
Socket s = new Socket();
int i = s.getLocalPort();
System.out.println(i);
}
}