Socket Programming Ports

Reply

Join Date: Mar 2009
Posts: 123
Reputation: neutralfox is an unknown quantity at this point 
Solved Threads: 0
neutralfox neutralfox is offline Offline
Junior Poster

Socket Programming Ports

 
0
  #1
May 23rd, 2009
Hello friends,
As usual .. when i have a problem ... daniweb.com is here . So I need some information from you. Ok, let me explain ... I am currently developing a chat application ! Ok ... everything works fine till now but I have doubts.

My application uses 3 ports, one for the general chat room, one for personal chat and one for file transfer. I have used 3 random ports .. 4321, 4532 and 4533.

Is there a standard port to used?

What will happen if I run this application on a computer where these 3 ports is in used?

And finally, how to know if a port is in used or not ?

Thanks a lot for your answers guys.

Regards,
Mike.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Socket Programming Ports

 
0
  #2
May 23rd, 2009
http://www.iana.org/assignments/port-numbers
You definitely need to avoid anything with a published port number.

As for picking ports which are unused, it's a crap shoot.
I would suggest that you make the listening ports configurable.

If your s/w takes off and everyone wants to use it, then getting an assigned IANA port number would generally solve the problem.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Socket Programming Ports

 
0
  #3
May 23rd, 2009
Hi,
  • There are 65536 ports (TCP) i.e 0-65535
  • Port No 0 to 1023 are reserved for well known services (http, ftp, telnet)
  • If you try to use a port already in use, you will get a BindException
  • You can run a port scanner program to check what your ports are doing
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 123
Reputation: neutralfox is an unknown quantity at this point 
Solved Threads: 0
neutralfox neutralfox is offline Offline
Junior Poster

Re: Socket Programming Ports

 
0
  #4
May 23rd, 2009
Thanks for the answer guys! To Salem, you suggest me to allow the user to configure or set the port himself? OK, but will it make my program less user friendly ?

I understand you but how MSN works ?

To tuse, I got your point ... I must create a form to allow the user to choose another port if there is a BindException. Thanks...

But still I want to know MSN Messenger works !!! I made some research but can't find anything useful that can help me to make my program more efficient.

Thanks a lot for your answers.
Regards,
Mike
Last edited by neutralfox; May 23rd, 2009 at 10:21 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Socket Programming Ports

 
0
  #5
May 23rd, 2009
Originally Posted by neutralfox View Post

To tuse, I got your point ... I must create a form to allow the user to choose another port if there is a BindException.

Yeah, using the try-catch
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 123
Reputation: neutralfox is an unknown quantity at this point 
Solved Threads: 0
neutralfox neutralfox is offline Offline
Junior Poster

Re: Socket Programming Ports

 
0
  #6
May 23rd, 2009
Thanks tuse.

@ Salem, in the link you send me:

Mention that:

"CCP Registered ports SHOULD NOT be used without IANA registration.
The registration procedure is defined in [RFC4340], Section 19.9."

So I can't use port 0 - 49151.
What happened if i used one of these ports ? Will I have to pay a fine? And how much is the registration ?

Because its just a open source software which I am developing for learning and to share among friends.

Thanks a lot for your answers.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 972
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 146
JamesCherrill JamesCherrill is offline Offline
Posting Shark

Re: Socket Programming Ports

 
0
  #7
May 23rd, 2009
If you use a port in the non-restricted range you would be unlucky to hit one that was in use. Maybe all you need to do if you do get a BindException is to just try the next one (etc) until its OK.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC