Struct cobalt::shared::Socket
[−]
[src]
pub struct Socket { // some fields omitted }
A Non-blocking abstraction over a UDP socket.
The non-blocking behavior is implement using a thread internally.
The implementation guarantees that the internal thread exits cleanly in case of either the sockets shutdown or it getting dropped.
Methods
impl Socket
[src]
fn new<T: ToSocketAddrs>(address: T, max_packet_size: usize) -> Result<Socket, Error>
Tries to create a new UDP socket by binding to the specified address.
fn local_addr(&self) -> Result<SocketAddr, Error>
Returns the socket address of the underlying UdpSocket.
fn reader(&mut self) -> Option<SocketReader>
Returns the channel receiver for incoming UDP packets.
The SocketReader
will be moved out; thus, the method will return
None
on all subsequent calls.
fn send<T: ToSocketAddrs>(&self, addr: T, data: &[u8]) -> Result<usize, Error>
Sends data
to the specified remote address.
fn shutdown(&mut self)
Shuts down the socket by stopping its internal reader thread.