Link to home
Start Free TrialLog in
Avatar of bhuvan_reddy
bhuvan_reddy

asked on

registering a port for my application

Hi,
I am developing a windows application (c#.NET) and it should use two ports for communication.

Is there any way to reserve two ports for my application permenetly ,i mean even if my application is not in use those two ports should not be used by anyother applications.
Do i need to update any registry variable.
Avatar of ptupapers
ptupapers

Yes you can do that.

You just need to create a new multi-string-value inside registry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters with name ReservedPorts. The value of the ReservedPorts will be the range of ports you want to reserve. e.g. 2000-2005 or 2000-2000 etc.


When your application starts, you need to delete the value so that the port become unreserved and your apllication could use it.
Before exiting create the same key again.

more info Here :
http://support.microsoft.com/kb/812873

Avatar of bhuvan_reddy

ASKER

Hi ptupapers,
Thanks for the info but if i do the above method it only restricts the applications which requests for random port numbers but if any application specifically requests the ports which are reserved by my application then they can also use the ports. I don't want that to happen.
is there any way to register the ports only for my application
example:
if b.exe is my application then is there any way that i can tell to system to register some ports only to b.exe  so tht no other application can register.
ASKER CERTIFIED SOLUTION
Avatar of ptupapers
ptupapers

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial