Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   TCPSocket error (http://www.velocityreviews.com/forums/t811620-tcpsocket-error.html)

Noah 11-08-2003 10:22 PM

TCPSocket error
 
Hi all, I'm new to Ruby; I have done some Python and Perl in the past, but
just started with Ruby a few days ago.
Anyhow, when I try to open a new TCPSocket connection like so:

t = TCPSocket.new('localhost', 'http')
print t.gets
t.close

I get the following error:

socktest.rb:1:in `new': No such file or directory (Errno::ENOENT)
from socktest.rb:1

What am I doing wrong? If I make a new socket on a port where I don't have
a service listening, it will give the expected error about the target
machine refusing the connection.

ruby 1.6.8 (2002-12-24) [i586-mswin32] on WinXP-Pro

Thanks in advance,
-Noah




Chris Reay 11-10-2003 02:42 AM

Re: TCPSocket error
 
"Noah" <noahd@juno.nospam.com> wrote in message news:
> So the exact code is:
>
> require "socket"
> t = TCPSocket.new('127.0.0.1', 'http')
> print t.gets
> t.close
>
> with error:
>
> 6sock2.rb:2:in `new': No such file or directory (Errno::ENOENT)
> from 6sock2.rb:2


From the Pickaxe book, IO.gets ...

"The stream must be opened for reading or an IOError will be raised."

How about

print t.recv(1024)

That's what I use. Hth.

Chris

Noah 11-10-2003 06:35 PM

Re: TCPSocket error
 

"Chris Reay" <mrchameleon@hotmail.com> wrote in message
news:7652139e.0311091842.1d170043@posting.google.c om...
> "Noah" <noahd@juno.nospam.com> wrote in message news:
> > So the exact code is:
> >
> > require "socket"
> > t = TCPSocket.new('127.0.0.1', 'http')
> > print t.gets
> > t.close
> >
> > with error:
> >
> > 6sock2.rb:2:in `new': No such file or directory (Errno::ENOENT)
> > from 6sock2.rb:2

>
> From the Pickaxe book, IO.gets ...
>
> "The stream must be opened for reading or an IOError will be raised."
>
> How about
>
> print t.recv(1024)
>
> That's what I use. Hth.
>
> Chris


Thanks, but that didn't help. The error happens on the TCPSocket.new
command.




Mike Stok 11-10-2003 08:00 PM

Re: TCPSocket error
 
In article <cd6cbee83ab63b859cdb6e54544ecf1e@news.bubbanews.c om>,
Noah <noahd@juno.nospam.com> wrote:

>"Chris Reay" <mrchameleon@hotmail.com> wrote in message
>news:7652139e.0311091842.1d170043@posting.google. com...
>> "Noah" <noahd@juno.nospam.com> wrote in message news:
>> > So the exact code is:
>> >
>> > require "socket"
>> > t = TCPSocket.new('127.0.0.1', 'http')
>> > print t.gets
>> > t.close
>> >
>> > with error:
>> >
>> > 6sock2.rb:2:in `new': No such file or directory (Errno::ENOENT)
>> > from 6sock2.rb:2

>>
>> From the Pickaxe book, IO.gets ...
>>
>> "The stream must be opened for reading or an IOError will be raised."
>>
>> How about
>>
>> print t.recv(1024)
>>
>> That's what I use. Hth.
>>
>> Chris

>
>Thanks, but that didn't help. The error happens on the TCPSocket.new
>command.


This is a wild guess, but might a shared library be missing, or the file
used to look up the port of the http service (/etc/services) be missing.

I would use something like strace (if it's on a unix-like system) to see
if there really is a file missing. If there is a file missing then
we can move on.

One quick thing might be to try

t = TCPSocket.new('127.0.0.1', 80)

to see if the problem is in the service name lookup.

Hope this helps,

Mike


--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60
http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA


All times are GMT. The time now is 09:33 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.