• Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket Programming Ports

 
Mikael Fox
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,
As usual .. when i have a problem ... coderanch.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.
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I were you, I would use the higher ports: 20000+. The reason is that other applications and the OS often use ports in the 1025-10000 range, so your chances of conflict is higher.

If a port is in use, you will get an exception telling you about it.

To find out if it is, you can try to bind to it, you can ask the OS(how this is done depends on the OS), or use a port scanner such as nmap.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!