Struct scaproust::Socket
[−]
[src]
pub struct Socket { /* fields omitted */ }
Socket is what applications use to exchange messages.
It is an abstraction of an application's "connection" to a messaging topology. Applications can have more than one Socket open at a time.
Methods
impl Socket
[src]
fn create_poll_req(&self, recv: bool, send: bool) -> PollReq
[src]
Creates a poll request that can be used to initialize a probe. The probe will then allow polling a group of sockets
fn connect(&mut self, url: &str) -> Result<Endpoint>
[src]
Adds a remote endpoint to the socket.
The library would then try to connect to the specified remote endpoint.
The addr argument consists of two parts as follows: transport://address
.
The transport specifies the underlying transport protocol to use.
The meaning of the address part is specific to the underlying transport protocol.
Note that bind and connect may be called multiple times on the same socket,
thus allowing the socket to communicate with multiple heterogeneous endpoints.
On success, returns an Endpoint that can be later used to remove the endpoint from the socket.
fn bind(&mut self, url: &str) -> Result<Endpoint>
[src]
Adds a local endpoint to the socket. The endpoint can be then used by other applications to connect to.
The addr argument consists of two parts as follows: transport://address
.
The transport specifies the underlying transport protocol to use.
The meaning of the address part is specific to the underlying transport protocol.
Note that bind and connect may be called multiple times on the same socket,
thus allowing the socket to communicate with multiple heterogeneous endpoints.
On success, returns an Endpoint that can be later used to remove the endpoint from the socket.
fn send(&mut self, buffer: Vec<u8>) -> Result<()>
[src]
Sends a buffer. Which of the peers the buffer will be sent to is determined by the protocol.
fn send_msg(&mut self, msg: Message) -> Result<()>
[src]
Sends a message. Which of the peers the message will be sent to is determined by the protocol.
fn try_send(&mut self, buffer: Vec<u8>) -> Result<()>
[src]
Non-blocking version of the send method.
fn try_send_msg(&mut self, msg: Message) -> Result<()>
[src]
Non-blocking version of the send_msg method.
fn recv(&mut self) -> Result<Vec<u8>>
[src]
Receives a buffer.
fn recv_msg(&mut self) -> Result<Message>
[src]
Receives a message.
fn try_recv(&mut self) -> Result<Vec<u8>>
[src]
Non-blocking version of the recv method.
fn try_recv_msg(&mut self) -> Result<Message>
[src]
Non-blocking version of the recv_msg method.
fn set_send_timeout(&mut self, timeout: Option<Duration>) -> Result<()>
[src]
Sets the timeout for send operation on the socket.
If message cannot be sent within the specified timeout,
an error with the kind TimedOut
is returned.
None means infinite timeout. Default value is None
.
fn set_recv_timeout(&mut self, timeout: Option<Duration>) -> Result<()>
[src]
Sets the timeout for recv operation on the socket.
If message cannot be received within the specified timeout,
an error with the kind TimedOut
is returned.
None
value means infinite timeout. Default value is None
.
fn set_send_priority(&mut self, priority: u8) -> Result<()>
[src]
Sets outbound priority for endpoints subsequently added to the socket.
This option has no effect on socket types that send messages to all the peers.
However, if the socket type sends each message to a single peer (or a limited set of peers),
peers with high priority take precedence over peers with low priority.
Highest priority is 1, lowest priority is 16. Default value is 8.
fn set_recv_priority(&mut self, priority: u8) -> Result<()>
[src]
Sets inbound priority for endpoints subsequently added to the socket.
This option has no effect on socket types that are not able to receive messages.
When receiving a message, messages from peer with higher priority
are received before messages from peer with lower priority.
Highest priority is 1, lowest priority is 16. Default value is 8.
fn set_tcp_nodelay(&mut self, value: bool) -> Result<()>
[src]
This option, when set to true
, disables Nagle’s algorithm.
It also disables delaying of TCP acknowledgments.
Using this option improves latency at the expense of throughput.
Default value is false
.
fn set_option(&mut self, cfg_opt: ConfigOption) -> Result<()>
[src]
Sets a socket option. See ConfigOption to get the list of options.