`How to catch Errno::ECONNRESET error?
D
D
Denis Savitsky2012-03-19 21:02:07
ruby
Denis Savitsky, 2012-03-19 21:02:07

How to catch Errno::ECONNRESET error?

How can you catch a tiny application opening a socket and accepting connections with an error:
`eof?': Connection reset by peer (Errno::ECONNRESET)

The code is:

# Received a connect to the server (listening) socket. <br>
          if sock == @server_socket<br>
           #sock - TCPServer.accept socket<br>
            accept_new_connection<br>
<br>
          else<br>
<br>
            # Received something on a client socket<br>
            if sock.eof?<br>
<br>
              sock.close<br>
              @descriptors.delete(sock)<br>
<br>
            end<br>
          end

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Taraev, 2012-03-19
@qweewq

rescue Errno::ECONNRESET => error
raise error.inspect

D
Denis Savitsky, 2012-03-20
@qweewq

thank! )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question