Module net/tcp
net/tcp
Async TCP networking — listeners and streams with Exception-based error handling.
Types
TcpListener
object
TcpListener
A TCP socket that listens for incoming connections.
Fields
| Name | Type | Description |
|---|---|---|
_fd | i32 | |
_local_addr | SocketAddr | |
_is_closed | bool |
Trait Implementations
impl(TcpListener, ...)
bind : (TcpListener) fn(addr : SocketAddr, using(io : IO)) -> Impl(Future(TcpListener, IO, Exception))Bind to a socket address and start listening.
Parameters
| Name | Type | Notes |
|---|---|---|
addr | SocketAddr |
Returns: Impl(Future(TcpListener, IO, Exception))
accept : (TcpListener) fn(self : TcpListener, using(io : IO)) -> Impl(Future(TcpStream, IO, Exception))local_addr : (TcpListener) fn(self : TcpListener) -> SocketAddrGet the local address this listener is bound to.
Parameters
| Name | Type | Notes |
|---|---|---|
self | TcpListener |
Returns: SocketAddr
close : (TcpListener) fn(self : TcpListener, using(io : IO)) -> Impl(Future(unit, IO, Exception))fd : (TcpListener) fn(self : TcpListener) -> i32impl(TcpListener, Dispose(...))
dispose : (fn(self: Self) -> unit)Returns: unit
TcpStream
object
TcpStream
A connected TCP stream for bidirectional data transfer.
Fields
| Name | Type | Description |
|---|---|---|
_fd | i32 | |
_peer_addr | SocketAddr | |
_is_closed | bool |
Trait Implementations
impl(TcpStream, ...)
connect : (TcpStream) fn(addr : SocketAddr, using(io : IO)) -> Impl(Future(TcpStream, IO, Exception))read : (TcpStream) fn(self : TcpStream, buf : *(u8), size : usize, using(io : IO)) -> Impl(Future(i32, IO, Exception))write_str : (TcpStream) fn(self : TcpStream, data : str, using(io : IO)) -> Impl(Future(i32, IO, Exception))write_string : (TcpStream) fn(self : TcpStream, data : String, using(io : IO)) -> Impl(Future(i32, IO, Exception))write_bytes : (TcpStream) fn(self : TcpStream, data : ArrayList(u8), using(io : IO)) -> Impl(Future(i32, IO, Exception))read_bytes : (TcpStream) fn(self : TcpStream, using(io : IO)) -> Impl(Future(ArrayList(u8), IO, Exception))shutdown : (TcpStream) fn(self : TcpStream, how : i32, using(io : IO)) -> Impl(Future(unit, IO, Exception))close : (TcpStream) fn(self : TcpStream, using(io : IO)) -> Impl(Future(unit, IO, Exception))peer_addr : (TcpStream) fn(self : TcpStream) -> SocketAddrfd : (TcpStream) fn(self : TcpStream) -> i32set_nodelay : (TcpStream) fn(self : TcpStream, nodelay : bool, using(io : IO)) -> Impl(Future(unit, IO, Exception))impl(TcpStream, Dispose(...))
dispose : (fn(self: Self) -> unit)Returns: unit