pub struct Socket { /* private fields */ }Implementations§
Source§impl Socket
impl Socket
pub fn bind(addr: impl ToSocketAddrs) -> Result<Socket, Error>
pub fn connect(addr: impl ToSocketAddrs) -> Result<Socket, Error>
pub fn local_addr(&self) -> Result<SocketAddr, Error>
pub fn send(&self, bytes: &[u8]) -> Result<usize, Error>
pub fn send_to(&self, bytes: &[u8], addr: SocketAddr) -> Result<usize, Error>
Sourcepub fn recv_from(
&self,
buffer: &mut [u8; 1201],
) -> Result<Option<(usize, SocketAddr)>, Error>
pub fn recv_from( &self, buffer: &mut [u8; 1201], ) -> Result<Option<(usize, SocketAddr)>, Error>
The extra byte detects oversized/truncated UDP datagrams. Pass the result to the codec, which rejects lengths above MAX_PACKET_BYTES. Windows discards oversized datagrams and returns InvalidData; callers should count those as rejected packets and continue their poll budget. Only an empty socket returns None.
Auto Trait Implementations§
impl Freeze for Socket
impl RefUnwindSafe for Socket
impl Send for Socket
impl Sync for Socket
impl Unpin for Socket
impl UnwindSafe for Socket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more