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.

Recommended Answers

All 6 Replies

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.

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

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


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

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.