Struct Socket

Source
pub struct Socket { /* private fields */ }

Implementations§

Source§

impl Socket

Source

pub fn new( socket_family: i32, socket_type: i32, protocol: i32, ) -> Result<Socket>

Source

pub fn fileno(&self) -> i32

Returns the underlying file descriptor.

Source

pub fn setsockopt<T>(&self, level: i32, name: i32, value: T) -> Result<()>

Source

pub fn bind<T: ToSocketAddrs + ?Sized>(&self, address: &T) -> Result<()>

Binds socket to an address

Source

pub fn getsockname(&self) -> Result<SocketAddr>

Source

pub fn sendto<T: ToSocketAddrs + ?Sized>( &self, buffer: &[u8], flags: i32, address: &T, ) -> Result<usize>

Source

pub fn send(&self, buffer: &[u8], flags: i32) -> Result<usize>

Source

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.

Source

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.

Source

pub fn recv(&self, bytes: usize, flags: i32) -> Result<Box<[u8]>>

Returns up to bytes bytes received from the remote socket.

Source

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.

Source

pub fn connect<T: ToSocketAddrs + ?Sized>(&self, toaddress: &T) -> Result<()>

Source

pub fn listen(&self, backlog: i32) -> Result<()>

Source

pub fn accept(&self) -> Result<(Socket, SocketAddr)>

Source

pub fn close(&self) -> Result<()>

Source

pub fn shutdown(&self, how: i32) -> Result<()>

Trait Implementations§

Source§

impl Debug for Socket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Socket

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.