From: Hassan Schroeder Date: 2009-03-01T07:49:17+09:00 Subject: Re: Gets the broadcast address of an IP address On Sat, Feb 28, 2009 at 11:12 AM, Eleanor McHugh wrote: >> ... But is there a way to get automatically the >> "192.168.0.255" address thanks to a Ruby method?  I know I can get my IP >> with IPSocket.getaddress(Socket.gethostname) but I don't see any way to >> gets its broadcast address. > The simplest way to do it is to use a regex to change the last term in the > quad: > > IPSocket.getaddress(Socket.gethostname).gsub!(/.\d{1,3}$/, '.255') Simple but not necessarily correct :-) FWIW, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com