Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: What's the best way to find an unused TCP port on the local system

by ikegami (Patriarch)
on Oct 20, 2006 at 20:11 UTC ( [id://579694]=note: print w/replies, xml ) Need Help??


in reply to Re^2: What's the best way to find an unused TCP port on the local system
in thread What's the best way to find an unused TCP port on the local system

This is not a Perl "trick". It's a feature of the system's socket library. You can use port 0 in C++ as well.
  • Comment on Re^3: What's the best way to find an unused TCP port on the local system

Replies are listed 'Best First'.
Re^4: What's the best way to find an unused TCP port on the local system
by DrWhy (Chaplain) on Oct 20, 2006 at 21:43 UTC
    It must be a feature only of Unix(-like) systems, then. I'm working in a Windows XP environment and just tried it out with our c++ server and instead of picking a random port it actually connected to port number 0.

    Updated: No, it works as described in the previous post. Our server is just reporting (incorrectly) that it is connected to port 0.

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

      No, it works on Windows XP as well. bind() is what typically assigns the port number. But this has become quite off topic. There are lots of choices for networking APIs to use in Windows XP from C++, so you should probably consult the documentation for whichever one you are using.

      - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://579694]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-18 00:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found