pub struct Socket { /* private fields */ }
Implementations§
Source§impl Socket
impl Socket
pub fn new( socket_family: i32, socket_type: i32, protocol: i32, ) -> Result<Socket>
pub fn setsockopt<T>(&self, level: i32, name: i32, value: T) -> Result<()>
Sourcepub fn bind<T: ToSocketAddrs + ?Sized>(&self, address: &T) -> Result<()>
pub fn bind<T: ToSocketAddrs + ?Sized>(&self, address: &T) -> Result<()>
Binds socket to an address
pub fn getsockname(&self) -> Result<SocketAddr>
pub fn sendto<T: ToSocketAddrs + ?Sized>( &self, buffer: &[u8], flags: i32, address: &T, ) -> Result<usize>
pub fn send(&self, buffer: &[u8], flags: i32) -> Result<usize>
Sourcepub fn recvfrom(
&self,
bytes: usize,
flags: i32,
) -> Result<(SocketAddr, Box<[u8]>)>
pub fn recvfrom( &self, bytes: usize, flags: i32, ) -> Result<(SocketAddr, Box<[u8]>)>
Receives data from a remote socket and returns it with the address of the socket.
Sourcepub fn recvfrom_into(
&self,
buffer: &mut [u8],
flags: i32,
) -> Result<(SocketAddr, usize)>
pub fn recvfrom_into( &self, buffer: &mut [u8], flags: i32, ) -> Result<(SocketAddr, usize)>
Similar to recvfrom
but receives to predefined buffer and returns the number
of bytes read.
Sourcepub fn recv(&self, bytes: usize, flags: i32) -> Result<Box<[u8]>>
pub fn recv(&self, bytes: usize, flags: i32) -> Result<Box<[u8]>>
Returns up to bytes
bytes received from the remote socket.
Sourcepub fn recv_into(&self, buffer: &mut [u8], flags: i32) -> Result<usize>
pub fn recv_into(&self, buffer: &mut [u8], flags: i32) -> Result<usize>
Similar to recv
but receives to predefined buffer and returns the number
of bytes read.
pub fn connect<T: ToSocketAddrs + ?Sized>(&self, toaddress: &T) -> Result<()>
pub fn listen(&self, backlog: i32) -> Result<()>
pub fn accept(&self) -> Result<(Socket, SocketAddr)>
pub fn close(&self) -> Result<()>
pub fn shutdown(&self, how: i32) -> Result<()>
Trait Implementations§
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