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, io : Io) -> Impl(Future(TcpListener, IoExn))Bind to a socket address and start listening.
Parameters
| Name | Type | Notes |
|---|---|---|
addr | SocketAddr | |
io | Io |
Returns: Impl(Future(TcpListener, IoExn))
accept : (TcpListener) fn(self : TcpListener, io : Io) -> Impl(Future(TcpStream, IoExn))Accept an incoming connection, returning a new TcpStream.
Parameters
| Name | Type | Notes |
|---|---|---|
self | TcpListener | |
io | Io |
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, io : Io) -> Impl(Future(unit, IoExn))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, io : Io) -> Impl(Future(TcpStream, IoExn))Connect to a remote address, returning a new TcpStream.
Parameters
| Name | Type | Notes |
|---|---|---|
addr | SocketAddr | |
io | Io |
read : (TcpStream) fn(self : TcpStream, buf : *(u8), size : usize, io : Io) -> Impl(Future(i32, IoExn))write_str : (TcpStream) fn(self : TcpStream, data : str, io : Io) -> Impl(Future(i32, IoExn))write_string : (TcpStream) fn(self : TcpStream, data : String, io : Io) -> Impl(Future(i32, IoExn))write_bytes : (TcpStream) fn(self : TcpStream, data : ArrayList(u8), io : Io) -> Impl(Future(i32, IoExn))read_bytes : (TcpStream) fn(self : TcpStream, io : Io) -> Impl(Future(ArrayList(u8), IoExn))shutdown : (TcpStream) fn(self : TcpStream, how : i32, io : Io) -> Impl(Future(unit, IoExn))close : (TcpStream) fn(self : TcpStream, io : Io) -> Impl(Future(unit, IoExn))peer_addr : (TcpStream) fn(self : TcpStream) -> SocketAddrfd : (TcpStream) fn(self : TcpStream) -> i32set_nodelay : (TcpStream) fn(self : TcpStream, nodelay : bool, io : Io) -> Impl(Future(unit, IoExn))impl(TcpStream, Dispose(...))
dispose : (fn(self : Self) -> unit)Returns: unit