From: Tom Sawyer Date: 2002-09-10T03:38:50+09:00 Subject: Re: getting the IP address of the local machine no problemo, it was eductional! On Mon, 2002-09-09 at 12:32, M Mohr wrote: > Dan Debertin writes: > > > At Tue, 10 Sep 2002 00:31:36 +0900, M Mohr wrote: > > > > oh and one other thing: how to find a free port? > > > > > > you have to search a free port with trial-and-error AFAIK. > > > (maybe this can be done more elegant, I'm pretty new to ruby) : > > > > Ouch, ouch, ouch. There's no need to do this. Just do what you'd do in > > C -- bind to port 0, and let the system choose a port for you: > > > > s = TCPServer.new('0', '0') # Bind to all interfaces, with any port > > # > 1024. > > doh', I didn't know about that. sorry for the confusion. > > > (a quick grep through netstat shows that I got port 48944 this time). > > > > The client classes (TCPSocket, etc.) will have a port allocated > > dynamically in the same way. > > > > Dan > -- tom sawyer, aka transami transami@transami.net