C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 02-26-2005, 04:58 PM   #1
Politics&Cpp geek
 
Da-Nuka's Avatar
 
Join Date: Oct 2004
Posts: 104
portnumbers

If I have got it right, I can use any portnumber for my program?
(In theory?)

Like if im making a chat server/client,
I can actually make my chat clients/servers speak to each other through port 80?

Or do I have to chose a "unserserved" portnumber?
__________________
http://livebad.com/nuka
Da-Nuka
Da-Nuka is offline   Reply With Quote
Old 02-26-2005, 05:03 PM   #2
Registered User
 
Join Date: Sep 2004
Location: California
Posts: 3,020
Yes, you can bind to any port that is not already in use, and is less than 65356. To bind to a port under 1024 requires root access on most *nix setups though.
bithub is offline   Reply With Quote
Old 02-27-2005, 01:57 PM   #3
Registered User
 
Join Date: Nov 2001
Posts: 1,348
You can potentially bind to any port you want. The issue arises when it is a common port used for something else. Then other apps and services may not function correctly.

Kuphryn
kuphryn is offline   Reply With Quote
Old 02-27-2005, 02:15 PM   #4
Hamster without a wheel
 
iain's Avatar
 
Join Date: Aug 2001
Posts: 1,385
Ports are reverved for good reasons, you should not really use ports below 1024.
Common ports: (invalid link removed)
__________________
Monday - what a way to spend a seventh of your life

Last edited by iain; 02-27-2005 at 02:24 PM. Reason: bad link removed
iain is offline   Reply With Quote
Old 02-27-2005, 02:21 PM   #5
Registered User
 
Join Date: Sep 2004
Posts: 197
You can use any port EXCEPT 0 (commonly used by OS's to give you a random port actually, and is considered reserved by IANA). As it was mentioned most *nix variants protect ports 1024 and below. I would suggest using an unreserved port any ways though, as you don't have to worry about steping on any toes (so to speak), incase it is being used.

Iain, I don't see any ports listed on that site, a beter choice would to just go to the source (IANA) any how, as they keep the up to date list on the web. This can be found at http://www.iana.org/assignments/port-numbers



Oh, and some trivia, can you guess who got the port 666 assigned to them?
__________________
If any part of my post is incorrect, please correct me.

This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

Last edited by Xipher; 02-27-2005 at 02:27 PM.
Xipher is offline   Reply With Quote
Old 02-27-2005, 02:23 PM   #6
Hamster without a wheel
 
iain's Avatar
 
Join Date: Aug 2001
Posts: 1,385
sorry, wrong link!
__________________
Monday - what a way to spend a seventh of your life
iain is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 04:02 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22