Class | FTW::Connection |
In: |
lib/ftw/connection.rb
lib/ftw/connection.rb |
Parent: | Object |
A network connection. This is TCP.
You can use IO::select on this objects of this type. (at least, in MRI you can)
You can activate SSL/TLS on this connection by invoking FTW::Connection#secure
This class also implements buffering itself because some IO-like classes (OpenSSL::SSL::SSLSocket) do not support IO#ungetbyte
A new network connection. The ‘destination’ argument can be an array of strings or a single string. String format is expected to be "host:port"
Example:
conn = FTW::Connection.new(["1.2.3.4:80", "1.2.3.5:80"])
If you specify multiple destinations, they are used in a round-robin decision made during reconnection.
A new network connection. The ‘destination’ argument can be an array of strings or a single string. String format is expected to be "host:port"
Example:
conn = FTW::Connection.new(["1.2.3.4:80", "1.2.3.5:80"])
If you specify multiple destinations, they are used in a round-robin decision made during reconnection.
Connect now.
Timeout value is optional. If no timeout is given, this method blocks until a connection is successful or an error occurs.
You should check the return value of this method to determine if a connection was successful.
Possible return values are on error include:
@return [nil] if the connection was successful @return [StandardError or subclass] if the connection failed
Connect now.
Timeout value is optional. If no timeout is given, this method blocks until a connection is successful or an error occurs.
You should check the return value of this method to determine if a connection was successful.
Possible return values are on error include:
@return [nil] if the connection was successful @return [StandardError or subclass] if the connection failed
Is this connection readable? Returns true if it is readable within the timeout period. False otherwise.
The time out is in seconds. Fractional seconds are OK.
Is this connection readable? Returns true if it is readable within the timeout period. False otherwise.
The time out is in seconds. Fractional seconds are OK.
Secure this connection with TLS.
Options:
Both `certificate` and `key` are highly recommended if the connection belongs to a server (not a client connection).
Notes:
OpenSSL, etc.
Secure this connection with TLS.
Options:
Both `certificate` and `key` are highly recommended if the connection belongs to a server (not a client connection).
Notes:
OpenSSL, etc.
Is this connection writable? Returns true if it is writable within the timeout period. False otherwise.
The time out is in seconds. Fractional seconds are OK.
Is this connection writable? Returns true if it is writable within the timeout period. False otherwise.
The time out is in seconds. Fractional seconds are OK.
Write data to this connection. This method blocks until the write succeeds unless a timeout is given.
This method is not guaranteed to have written the full data given.
Returns the number of bytes written (See also IO#syswrite)
Write data to this connection. This method blocks until the write succeeds unless a timeout is given.
This method is not guaranteed to have written the full data given.
Returns the number of bytes written (See also IO#syswrite)