Class: Cod::TcpClient::Connection
- Inherits:
-
Object
- Object
- Cod::TcpClient::Connection
- Defined in:
- lib/cod/tcp_client.rb
Overview
Holds a connection that we don’t create and therefore don’t own. This is the case where a channel is created to communicate back to one of the TcpServers clients: the tcp server manages the back channels, so the created channel is lent its socket only.
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #close ⇒ Object
- #established? ⇒ Boolean
-
#initialize(socket) ⇒ Connection
constructor
:nodoc:.
- #read(serializer) ⇒ Object
- #try_connect ⇒ Object
- #write(buffer) ⇒ Object
Constructor Details
#initialize(socket) ⇒ Connection
:nodoc:
182 183 184 |
# File 'lib/cod/tcp_client.rb', line 182 def initialize(socket) @socket = socket.dup end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
185 186 187 |
# File 'lib/cod/tcp_client.rb', line 185 def socket @socket end |
Instance Method Details
#close ⇒ Object
197 198 199 |
# File 'lib/cod/tcp_client.rb', line 197 def close @socket.close end |
#established? ⇒ Boolean
188 189 190 |
# File 'lib/cod/tcp_client.rb', line 188 def established? true end |
#read(serializer) ⇒ Object
191 192 193 |
# File 'lib/cod/tcp_client.rb', line 191 def read(serializer) serializer.de(@socket) end |
#try_connect ⇒ Object
186 187 |
# File 'lib/cod/tcp_client.rb', line 186 def try_connect end |
#write(buffer) ⇒ Object
194 195 196 |
# File 'lib/cod/tcp_client.rb', line 194 def write(buffer) @socket.write(buffer) end |