Hello.
When writing socket programs which comunicate with eachother over IP, how do you choose which port they should use?
:confused:
What happens when another process tries to use the same port?
Cheers!
Printable View
Hello.
When writing socket programs which comunicate with eachother over IP, how do you choose which port they should use?
:confused:
What happens when another process tries to use the same port?
Cheers!
No insights?
Is is ok to just randomly choose a port number?
choose any nyumber above 2000 and you will be fine.
If two programs use same port then one will not work ;) ;)
HTH
:) :)
For good proper redundancy you might try selecting a wide range of port numbers. So your app will listen on port 2000, 2100, 2200, 2250, 2260, 2270, 2280, 2290, 2295, 2300
Chances are at least one should be free. And when another app is trying to connect, if it doesn't receive the correct handshake protocol upon connect, then that's another app already running on that computer...
Thanks fellas...
:)
OK I'm back..............
Right well the reason I was asking about ports is that I'm writing a windows service in VB.NET which accepts socket requests from client programs and verifies license information.
Sometimes, and only sometimes, I get the following error when trying to start the service:
"Only one usage of each socket address (protocol/network address/port) is normally permitted"
Now I've tried lots of different port numbers and this keeps happening now and again. Is it possible for a process to 'hold on' to a port after it has been stopped? Perhaps there is another reason for encountering this problem?
If you keep only one server winsock listening and then load up any new ones to accept the connection then you should avoid this.
it is a winsock problem where one has not released the port properly and will take up to a minute after finishing to free the port. :) :)
I THINK :D :D :D
Thing is.. it sometimes gives me this error messages even after I have just restarted the computer and run the service for the first time..