pub struct TcpSocket { /* private fields */ }p3 only.Expand description
A TCP socket resource.
The socket can be in one of the following states:
unboundbound(See note below)listeningconnectingconnectedclosedSee https://github.com/WebAssembly/WASI/blob/main/proposals/sockets/TcpSocketOperationalSemantics-0.3.0-draft.md for more information.
Note: Except where explicitly mentioned, whenever this documentation uses
the term “bound” without backticks it actually means: in the bound state or higher.
(i.e. bound, listening, connecting or connected)
WASI uses shared ownership semantics: the tcp-socket handle and all
derived stream and future values reference a single underlying OS
socket:
- Send/receive streams remain functional after the original
tcp-sockethandle is dropped. - The stream returned by
listenbehaves similarly. - Client sockets returned by
tcp-socket::listenare independent and do not keep the listening socket alive.
The OS socket is closed only after the last handle is dropped. This model has observable effects; for example, it affects when the local port binding is released.
In addition to the general error codes documented on the
types::error-code type, TCP socket methods may always return
error(invalid-state) when in the closed state.
A host TCP socket, plus associated bookkeeping.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TcpSocket
impl !RefUnwindSafe for TcpSocket
impl Send for TcpSocket
impl !Sync for TcpSocket
impl Unpin for TcpSocket
impl !UnwindSafe for TcpSocket
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
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more