pub struct UniSocket { /* private fields */ }Expand description
A simple wrapper of tokio::net::TcpSocket.
Implementations§
Source§impl UniSocket
impl UniSocket
Sourcepub fn new(addr: &UniAddr) -> Result<Self>
pub fn new(addr: &UniAddr) -> Result<Self>
Creates a new UniSocket, and applies the given initialization
function to the underlying socket.
The given address determines the socket type, and the caller should bind to / connect to the address later.
Sourcepub fn bind(self, addr: &UniAddr) -> Result<Self>
pub fn bind(self, addr: &UniAddr) -> Result<Self>
Binds the socket to the specified address.
Notes that the address must be the one used to create the socket.
Sourcepub fn listen(self, backlog: u32) -> Result<UniListener>
pub fn listen(self, backlog: u32) -> Result<UniListener>
Mark a socket as ready to accept incoming connection requests using
UniListener::accept.
This function directly corresponds to the listen(2) function on
Windows.
Sourcepub async fn connect(self, addr: &UniAddr) -> Result<UniStream>
pub async fn connect(self, addr: &UniAddr) -> Result<UniStream>
Initiates and completes a connection on this socket to the specified address.
This function directly corresponds to the connect(2) function on
Windows.
Sourcepub fn local_addr(&self) -> Result<UniAddr>
pub fn local_addr(&self) -> Result<UniAddr>
Sourcepub fn as_socket_ref(&self) -> SockRef<'_>
pub fn as_socket_ref(&self) -> SockRef<'_>
Returns a SockRef to the underlying socket for configuration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UniSocket
impl RefUnwindSafe for UniSocket
impl Send for UniSocket
impl Sync for UniSocket
impl Unpin for UniSocket
impl UnwindSafe for UniSocket
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