androidsocketsipport

What open/available port numbers and IP addresses can I use?


I am setting up a client and server software on two Android tablets using sockets programming. One Android tablet is the client and the other is the server.

In the sample code the author made the IP address and port number as shown below. What are my options for ports and IP addresses? If I choose a different port, what is the range of ports that I can use and what is the range of IP address I can use? That is if I don't want to use 10.0.2.15 for the IP and also use something different than 8080 as the port.

 // default ip
 public static String SERVERIP = "10.0.2.15";

 // designate a port
 public static final int SERVERPORT = 8080;

Solution

  • You don't need to specify an IP address in the server. Just use INADDR_ANY. For available port numbers you need to research the assigned port numbers at the IANA Registry and use one that isn't assigned.