summaryrefslogtreecommitdiff
path: root/docs/std/net.md
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-29 13:17:30 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-29 13:17:30 +0000
commitfc6ff10acb9d00ea1c8c5924869e0efbd38093c5 (patch)
treea4cb5d9d9d0ea2702de42df1e3c2fbe40185e293 /docs/std/net.md
parentda9e8758e9d89dc7362be67f8e7573309efe170c (diff)
Objective-C interop + a few improvements
Diffstat (limited to 'docs/std/net.md')
-rw-r--r--docs/std/net.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/docs/std/net.md b/docs/std/net.md
new file mode 100644
index 0000000..392c901
--- /dev/null
+++ b/docs/std/net.md
@@ -0,0 +1,44 @@
+# Networking (`std/net.zc`)
+
+The `std/net` module provides basic TCP networking capabilities.
+
+## Usage
+
+```zc
+import "std/net.zc"
+```
+
+## Types
+
+### Type `TcpListener`
+
+Represents a TCP socket listening for incoming connections.
+
+#### Methods
+
+- **`fn bind(host: char*, port: int) -> Result<TcpListener>`**
+ Creates a new listener bound to the specified host and port.
+
+- **`fn accept(self) -> Result<TcpStream>`**
+ Blocks waiting for a new connection. Returns a `TcpStream` for the connected client.
+
+- **`fn close(self)`**
+ Closes the listening socket.
+
+### Type `TcpStream`
+
+Represents a TCP connection stream.
+
+#### Methods
+
+- **`fn connect(host: char*, port: int) -> Result<TcpStream>`**
+ Connects to a remote host.
+
+- **`fn read(self, buf: char*, len: usize) -> Result<usize>`**
+ Reads up to `len` bytes into `buf`. Returns the number of bytes read.
+
+- **`fn write(self, buf: char*, len: usize) -> Result<usize>`**
+ Writes `len` bytes from `buf` to the stream. Returns the number of bytes written.
+
+- **`fn close(self)`**
+ Closes the connection.