Class: Cod::TcpClient::Connection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#socketObject (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

#closeObject



197
198
199
# File 'lib/cod/tcp_client.rb', line 197

def close
  @socket.close
end

#established?Boolean

Returns:

  • (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_connectObject



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