TCPSocket.new 'Bad file descriptor'

S

sean nakasone

Here's my very simple script to open a tcp port and write to it.

require 'socket'
s=TCPSocket.new("173.30.6.16", 9990)
s.write("Hello\n")
s.close

The TCPSocket.new returns with:

cli.rb:3:in `initialize': Bad file descriptor - connect(2) (Errno::EBADF)
from cli.rb:3:in `new'
from cli.rb:3


The IP address is the PC that I'm running the script from. I'm stumped
because if I replace "173.30.6.16" with "localhost" or "127.0.0.1", it
works. Any suggestions? I guess it could be a network security issue,
but how can I get around this?
 
S

SHiBuMi

Yes, it's most probably a network security issue. Check your firewall
settings, and in order to be sure, disable your firewall and try while
firewall is disabled.
 
A

Aryk Grosz

Im actually getting this error now as well, and I tried disabling my
firewall, and disabling the settings on my norton AntiVirus.

Ive tried

TCPSocket.new "localhost", <port>
TCPSocket.new "127.0.0.1", <port>
TCPSocket.new "<computer name>", <port>

These all give the same errors. My mongrel servers work fine as usual. I
don't know why Im having so much trouble making a TCPSocket connection.


Any thoughts?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top