|
-
November 12th, 2010, 05:59 AM
#1
what is valid range of port number to use sockaddr_in?
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.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
-
November 12th, 2010, 07:08 AM
#2
Re: what is valid range of port number to use sockaddr_in?
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.
-
November 12th, 2010, 07:23 AM
#3
Re: what is valid range of port number to use sockaddr_in?
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.
-
November 12th, 2010, 09:25 AM
#4
Re: what is valid range of port number to use sockaddr_in?
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.
-
November 12th, 2010, 09:40 AM
#5
Re: what is valid range of port number to use sockaddr_in?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|