hi all,
i m use sockaddr_in to cocket connection.
is there any valid range of pot number to establish connection or i can use any port number for connection.
please help me for this.
thanks in advance.
Printable View
hi all,
i m use sockaddr_in to cocket connection.
is there any valid range of pot number to establish connection or i can use any port number for connection.
please help me for this.
thanks in advance.
Hmmm, I would definitely love to hear some thoughts from everyone too. I guess is, you can not connect to an arbitrary port number. But ideas would still be more benefitial and worthy learning at best. Thank you.
You can use any port number that is not used by other application. Here is a list of known ports: http://en.wikipedia.org/wiki/List_of...P_port_numbers.
BTW, it should be possible for your application to change the port number, at least have a set of available ports that can be switched between.
The field is an unsigned short so the range is 0-65535 subject to port availability as suggested in the list above. Note that lists like this are only a very general guideline since the majority of these applications will not be in use on a typical computer and virtually any port (save for a very few common ones) that is available can be used.
You should also note that a port number is irrelevant if you are creating a client socket as one will be assigned to your connection automatically. It's only important if you are creating a server as you will need to use an available port to listen for incoming connections.
You should only use non-ephemeral ports: http://en.wikipedia.org/wiki/Ephemeral_ports
>> The IANA suggests 49152 to 65535 as "dynamic and/or private ports."
gg