Class: Net::PTTH::Socket
- Inherits:
-
Struct
- Object
- Struct
- Net::PTTH::Socket
- Includes:
- Celluloid::IO
- Defined in:
- lib/net/ptth/socket.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #close ⇒ Object
- #open? ⇒ Boolean
- #raw_socket ⇒ Object
- #read(bytes = 4096*10) ⇒ Object
- #write(data) ⇒ Object
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host
4 5 6 |
# File 'lib/net/ptth/socket.rb', line 4 def host @host end |
#port ⇒ Object
Returns the value of attribute port
4 5 6 |
# File 'lib/net/ptth/socket.rb', line 4 def port @port end |
Instance Method Details
#close ⇒ Object
15 16 17 18 19 |
# File 'lib/net/ptth/socket.rb', line 15 def close raw_socket.close rescue IOError => e # I'm already closed end |
#open? ⇒ Boolean
21 22 23 |
# File 'lib/net/ptth/socket.rb', line 21 def open? !raw_socket.closed? end |
#raw_socket ⇒ Object
25 26 27 |
# File 'lib/net/ptth/socket.rb', line 25 def raw_socket @_socket ||= TCPSocket.new(host, port) end |
#read(bytes = 4096*10) ⇒ Object
7 8 9 |
# File 'lib/net/ptth/socket.rb', line 7 def read(bytes = 4096*10) raw_socket.readpartial(bytes) end |
#write(data) ⇒ Object
11 12 13 |
# File 'lib/net/ptth/socket.rb', line 11 def write(data) raw_socket.write(data) end |