[][src]Struct socket_collection::TcpSock

pub struct TcpSock { /* fields omitted */ }

TCP socket which by default is uninitialized. Asynchronous TCP socket wrapper with some specific behavior to our use cases:

  • TcpSock takes care of message serialization and it's boundaries - no need to mess with the byte stream.
  • The maximum message length is DEFAULT_MAX_PAYLOAD_SIZE.
  • Incoming/outgoing messages are buffered.
  • All messages are encrypted with EncryptContext and decrypted with DecryptContext that can be changed at any time.

The socket is uninitialized by default and will result with SocketError, if used.

Methods

impl TcpSock
[src]

Starts TCP connection. Returns immediately, so make sure to wait until the socket becomes writable.

Starts TCP connection and uses given socket configuration. Returns immediately, so make sure to wait until the socket becomes writable.

Wraps TcpStream and uses default socket configuration.

Wraps TcpStream and uses given socket configuration.

Specify data encryption context which will determine how outgoing data is encrypted.

Specify data decryption context which will determine how incoming data is decrypted.

Sets TCP SO_LINGER value for the underlying socket.

Set Time To Live value for the underlying TCP socket.

Retrieve Time To Live value.

Returns local socket address.

Returns the address of the remote peer socket is connected to.

Retrieve last socket error, if one exists.

Read message from the socket. Call this from inside the ready handler.

Returns:

  • Ok(Some(data)): data has been successfully read from the socket
  • Ok(None): there is not enough data in the socket. Call read() again in the next invocation of the ready handler.
  • Err(error): there was an error reading from the socket.

Write a message to the socket.

Returns:

  • Ok(true): the message has been successfully written.
  • Ok(false): the message has been queued, but not yet fully written. will be attempted in the next write schedule.
  • Err(error): there was an error while writing to the socket.

Trait Implementations

impl From<TcpSock> for Socket
[src]

impl Default for TcpSock
[src]

impl Debug for TcpSock
[src]

impl Evented for TcpSock
[src]

Auto Trait Implementations

impl Send for TcpSock

impl Sync for TcpSock

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> UnsafeAny for T where
    T: Any

impl<T> Same for T

Should always be Self