Method: Socketry::TCP::Socket#closed?

Defined in:
lib/socketry/tcp/socket.rb

#closed?true, false

Is the socket closed?

This method returns the local connection state. However, it’s possible the remote side has closed the connection, so it’s not actually possible to actually know if the socket is actually still open without reading from or writing to it. It’s sort of like the Heisenberg uncertainty principle of sockets.

Returns:

  • (true, false)

    do we locally think the socket is closed?



328
329
330
# File 'lib/socketry/tcp/socket.rb', line 328

def closed?
  @socket.nil?
end