From: botp Date: 2010-06-03T13:42:46+09:00 Subject: Re: TCPSocket error On Thu, Jun 3, 2010 at 4:08 AM, Ted Pon wrote: > I am a student learning ruby welcome :) > and I am getting an error that I can't > figure out. It works on my teacher's mac, however does not on my laptop. teachers are always ready ;) > Windows Vista 64-bit > My ruby version is: 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32] ok > Here is what I've tried in cmd > irb > irb(main):002:0> require 'socket' > => true > irb(main):005:0> TCPSocket.open('0.0.0.0', 8888) > Errno::EADDRNOTAVAIL: The requested address is not valid in its context. > - connect(2) hint. you need a pair ;-) you are trying to connect as a client to a server ip 0.0.0.0 thru port 8888 you'll need another server running on your host at 0.0.0.0 thru port 8888 note 0.0.0.0 as client and server is only accessible locally, ergo your client and server will treat you as local 127.0.0.1 (0.0.0.0 is just a def gw ip wc in this case, will route you to local 127.0.0.1) eg, $ script/server -p 8888 => Booting Mongrel => Rails 2.3.8 application starting on http://0.0.0.0:8888 => Call with -d to detach => Ctrl-C to shutdown server Processing Rails::InfoController#properties (for 127.0.0.1 at 2010-06-03 12:27:51) [GET] SQL (0.8ms) SELECT name FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence' Completed in 227ms (View: 17, DB: 1) | 200 OK [http://0.0.0.0/rails/info/properties] .... > s=TCPSocket.open('0.0.0.0', 8888) => # > s.peeraddr => ["AF_INET", 8888, "127.0.0.1", "127.0.0.1"] kind regards -botp