Class: Nonnative::ResetPeerSocketPair
- Inherits:
-
SocketPair
- Object
- SocketPair
- Nonnative::ResetPeerSocketPair
- Defined in:
- lib/nonnative/reset_peer_socket_pair.rb
Overview
Socket-pair variant used by the fault-injection proxy to simulate an abrupt connection reset.
When active, the proxy accepts a TCP connection and closes it with a zero linger timeout, so the
kernel sends a TCP RST instead of a graceful FIN. Clients observe a reset ("connection reset by
peer", Errno::ECONNRESET) rather than a clean end-of-stream, which is distinct from the graceful
close performed by CloseAllSocketPair.
This behavior is enabled by calling FaultInjectionProxy#reset_peer.
Instance Method Summary collapse
-
#connect(local_socket) ⇒ void
Resets the accepted socket by closing it with a zero linger timeout, forcing a TCP RST.
Methods inherited from SocketPair
Constructor Details
This class inherits a constructor from Nonnative::SocketPair
Instance Method Details
#connect(local_socket) ⇒ void
This method returns an undefined value.
Resets the accepted socket by closing it with a zero linger timeout, forcing a TCP RST.
22 23 24 25 26 27 |
# File 'lib/nonnative/reset_peer_socket_pair.rb', line 22 def connect(local_socket) Nonnative.logger.info "resetting socket '#{local_socket.inspect}' for 'reset_peer' pair" local_socket.setsockopt(Socket::Option.linger(true, 0)) local_socket.close end |