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
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host
6 7 8 |
# File 'lib/net/ptth/socket.rb', line 6 def host @host end |
#port ⇒ Object
Returns the value of attribute port
6 7 8 |
# File 'lib/net/ptth/socket.rb', line 6 def port @port end |
Instance Method Details
#close ⇒ Object
29 30 31 32 33 |
# File 'lib/net/ptth/socket.rb', line 29 def close close_socket rescue IOError => e # I'm already closed end |
#open? ⇒ Boolean
35 36 37 |
# File 'lib/net/ptth/socket.rb', line 35 def open? !raw_socket.closed? end |
#read(bytes = 4096*10) ⇒ Object
9 10 11 |
# File 'lib/net/ptth/socket.rb', line 9 def read(bytes = 4096*10) raw_socket.readpartial(bytes) end |
#write(data) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/net/ptth/socket.rb', line 13 def write(data) retry_count = 3 begin raw_socket.write(data) rescue Errno::EPIPE => e close unless open? retry_count -= 1 if retry_count > 0 retry else raise SocketError.new("Couldn't reconnect! Errno::EPIPE") end end end |