Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

ContributingCommunityRepository

Language Runtime

Built-ins

Standard Library

std.argsstd.assertstd.audiostd.envstd.fsstd.httpstd.netstd.jsonstd.parsestd.pathstd.processstd.regexstd.stringstd.timestd.url

Standard Library

std.net

Blocking TCP and UDP socket primitives.

Exported functions

pub def tcp_connect(address: String) -> TcpConnection

Connect to a TCP server address such as "127.0.0.1:8080".

pub def tcp_bind(address: String) -> TcpListener

Bind a TCP listener to an address such as "127.0.0.1:0".

pub def tcp_accept(listener: TcpListener) -> TcpConnection

Accept one inbound TCP connection.

pub def tcp_read(connection: TcpConnection, bytes: Int) -> List[Int]

Read up to the requested number of bytes from a TCP connection.

pub def tcp_read_text(connection: TcpConnection, bytes: Int) -> String

Read up to the requested number of bytes as UTF-8 text with lossy decoding.

pub def tcp_write(connection: TcpConnection, data: List[Int]) -> Int

Write bytes to a TCP connection and return the number of bytes written.

pub def tcp_write_text(connection: TcpConnection, text: String) -> Int

Write UTF-8 text to a TCP connection and return the number of bytes written.

pub def tcp_set_read_timeout(connection: TcpConnection, milliseconds: Int) -> Void

Set a TCP read timeout in milliseconds. Use 0 to clear the timeout.

pub def tcp_set_write_timeout(connection: TcpConnection, milliseconds: Int) -> Void

Set a TCP write timeout in milliseconds. Use 0 to clear the timeout.

pub def tcp_close(connection: TcpConnection) -> Void

Close a TCP connection handle.

pub def tcp_close_listener(listener: TcpListener) -> Void

Close a TCP listener handle.

pub def udp_bind(address: String) -> UdpSocket

Bind a UDP socket to an address such as "127.0.0.1:0".

pub def udp_connect(socket: UdpSocket, address: String) -> UdpSocket

Connect a UDP socket to a default peer address.

pub def udp_send(socket: UdpSocket, data: List[Int]) -> Int

Send bytes through a connected UDP socket.

pub def udp_send_text(socket: UdpSocket, text: String) -> Int

Send text through a connected UDP socket.

pub def udp_send_to(socket: UdpSocket, data: List[Int], address: String) -> Int

Send bytes to a UDP peer address.

pub def udp_send_text_to(socket: UdpSocket, text: String, address: String) -> Int

Send text to a UDP peer address.

pub def udp_recv(socket: UdpSocket, bytes: Int) -> List[Int]

Receive bytes from a connected UDP socket.

pub def udp_recv_text(socket: UdpSocket, bytes: Int) -> String

Receive text from a connected UDP socket with lossy UTF-8 decoding.

pub def udp_recv_from(socket: UdpSocket, bytes: Int) -> UdpPacket

Receive bytes and the sender address from an unconnected UDP socket.

pub def udp_recv_text_from(socket: UdpSocket, bytes: Int) -> UdpTextPacket

Receive text and the sender address from an unconnected UDP socket.

pub def udp_set_read_timeout(socket: UdpSocket, milliseconds: Int) -> Void

Set a UDP read timeout in milliseconds. Use 0 to clear the timeout.

pub def udp_set_write_timeout(socket: UdpSocket, milliseconds: Int) -> Void

Set a UDP write timeout in milliseconds. Use 0 to clear the timeout.

pub def udp_close(socket: UdpSocket) -> Void

Close a UDP socket handle.