Saturday, February 5, 2011

In Ruby how can I abort a connection with a RESET?

In any socket API the close() method closes a connection with a FIN. If I want to abort a connection with a RST how can I do it?

  • I am not sure about Ruby EventMachine, but if what that framework gives you is a normal Ruby TCPSocket, then you should be able to turn on SO_LINGER by doing something like this:

    linger = [1,0].pack('ii')
    sock.setsockopt(Socket::SO_SOCKET, Socket::SO_LINGER, linger)
    sock.close
    

0 comments:

Post a Comment