From: Dan Debertin Date: 2002-09-10T01:04:42+09:00 Subject: Re: getting the IP address of the local machine 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. (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 -- /^Dan Debertin$/ airboss@nodewarrior.org | Did I sleep a little too late, www.nodewarrior.org | or am I awake? --Byrne