Class: Revactor::TCP::Socket
TCP socket class, returned by Revactor::TCP.connect and Revactor::TCP::Listener#accept
Attributes
| Name | Read/write? |
|---|---|
| controller | R |
Public Class Methods
connect (host, port, options = {})
Connect to the specified host and port. Host may be a domain name or IP address. Accepts the following options:
:active - Controls how data is read from the socket. See the
documentation for #active=
:controller - The controlling actor, default Actor.current
:filter - An symbol/class or array of symbols/classes which implement
#encode and #decode methods to transform data sent and
received data respectively via Revactor::TCP::Socket.
Public Instance Methods
active= (state)
Enable or disable active mode data reception. State can be any of the following:
true - All received data is sent to the controlling actor
false - Receiving data is disabled
:once - A single message will be sent to the controlling actor
then active mode will be disabled
active? ()
Is the socket in active mode?
controller= (controller)
Set the controlling actor
read (length = nil)
Read data from the socket synchronously. If a length is specified then the call blocks until the given length has been read. Otherwise the call blocks until it receives any data.
readpartial (value = nil)
Monkeypatched readpartial routine inserted whenever Revactor‘s mongrel.rb is loaded. The value passed to this method is ignored, so it is not fully compatible with Socket‘s readpartial method.
Mongrel doesn‘t really care if we read more than Const::CHUNK_SIZE and readpartial doesn‘t really make sense in Revactor‘s API since read accomplishes the same functionality. So, in this implementation readpartial just calls read and returns whatever is available.
write (data)
Write data to the socket. The call blocks until all data has been written.
Protected Instance Methods
decode (data)
Decode data through the filter chain
encode (message)
Encode data through the filter chain
initialize_filter (*filterset)
Initialize filter change
on_connect ()
Rev::TCPSocket callback
symbol_to_filter (filter)
Lookup filters referenced as symbols