> I need to know programmatically if some port is available for using in
> a new socket.
> Is that possible and how?
If you bind to a port that's already in use, you should get a
WSAEADDRINUSE error.
Is that too crude?
--
Bert Hyman St. Paul, MN be...@iphouse.com
"Bert Hyman" <be...@iphouse.com> wrote in message
news:Xns9CCD5B1431B...@207.46.248.16...
I would use the GetTcpTable or GetUdpTable functions from the IP
Helper API library in Windows. Using those, you can see all of the
active TCP connections, and TCP and UDP listening ports. You can check
these tables to see which ports are currently being used and which are
not. That way you can choose what port you want to use if you are in
a dynamic port allocation situation.
If there is a very specific port you want to use, then you can do what
Bert said. Just catch the WSAEADDRINUSE error as he stated.
Tom Handal
> Does that work olso in DotNet?
The Socket.Bind() method will raise a SocketException if the chosen ip/port pair cannot be used.
--
Remy Lebeau (TeamB)