Class: Pwnlib::Tubes::Sock
Overview
Socket!
Constant Summary
Constants inherited from Tube
Instance Attribute Summary collapse
-
#sock ⇒ TCPSocket
(also: #io_out)
readonly
The socket object.
Instance Method Summary collapse
-
#close(direction = :both) ⇒ void
Close the TCPSocket if no arguments passed.
-
#initialize(host, port, timeout: nil) ⇒ Sock
constructor
Instantiate a Sock object.
Methods inherited from Tube
#gets, #interact, #puts, #recv, #recvall, #recvline, #recvn, #recvpred, #recvregex, #recvuntil, #send, #sendline, #unrecv
Constructor Details
#initialize(host, port, timeout: nil) ⇒ Sock
Instantiate a Pwnlib::Tubes::Sock object.
23 24 25 26 27 28 29 |
# File 'lib/pwnlib/tubes/sock.rb', line 23 def initialize(host, port, timeout: nil) super(timeout: timeout) @sock = TCPSocket.new(host, port) @sock.binmode @timeout = nil @closed = { read: false, write: false } end |
Instance Attribute Details
#sock ⇒ TCPSocket (readonly) Also known as: io_out
Returns The socket object.
13 14 15 |
# File 'lib/pwnlib/tubes/sock.rb', line 13 def sock @sock end |
Instance Method Details
#close(direction = :both) ⇒ void
This method returns an undefined value.
Close the TCPSocket if no arguments passed. Or close the direction in sock
.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pwnlib/tubes/sock.rb', line 43 def close(direction = :both) if direction == :both return if @sock.closed? @closed[:read] = @closed[:write] = true @sock.close else shutdown(*normalize_direction(direction)) end end |