BasicSocket Problems

Z

Zach Dennis

Everynow and then I get issues with using BasicSocket or any of its
subclasses. I continually get errors like:

listeners.rb:136:in `recv': An established connection was aborted by the
software in your host machine. - recvfrom(2) (Errno::ECONNABORTED)

On this one I have no clue. Should I try to resend my data?

or errors like:

Errno::EINVAL while doing a:
socket.puts "test" unless socket.closed?

I see that if a socket gets shutdown, it will not appear closed, but you
still can't use the socket.. is there any way to determine if a socket
shutdown?

irb(main):001:0> require 'socket';
irb(main):002:0* s = TCPSocket.new( 'www.google.com', 80 )
=> #<TCPSocket:0x2dc41c8>
irb(main):003:0> s.shutdown
=> 0
irb(main):004:0> s.puts "/GET"
Errno::EINVAL: Invalid argument
from (irb):4:in `write'
from (irb):4:in `puts'
from (irb):4
irb(main):005:0>

In my code I never manually call shutdown, but perhaps its getting
called w/o my help?

Zach
 
Z

Zach Dennis

The irb example should have been:

irb(main):001:0> require 'socket';
irb(main):002:0* s = TCPSocket.new( 'www.google.com', 80 )
=> #<TCPSocket:0x2dc41c8>
irb(main):003:0> s.shutdown unless s.closed?
=> 0
irb(main):004:0> s.puts "/GET"
Errno::EINVAL: Invalid argument
from (irb):4:in `write'
from (irb):4:in `puts'
from (irb):4
irb(main):005:0>
 

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
474,175
Messages
2,570,942
Members
47,491
Latest member
mohitk

Latest Threads

Top