akshat
akshat

Reputation: 15922

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?

Upvotes: 2

Views: 980

Answers (1)

Aaron Hinni
Aaron Hinni

Reputation: 14716

With a normal Ruby TCPSocket, you can turn on SO_LINGER by doing something like this:

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

Upvotes: 5

Related Questions