Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / tls
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
TcpListener
cajeta.io.net.TcpListener — a passive TCP listening socket: bind + listen
plus a blocking accept that returns one accepted connection as a
TcpStream. acceptAsync is the fiber-parking twin: it parks
the calling fiber (not the carrier thread) on the listening socket until a
connection is pending. The listener exposes its descriptor as the public fd
field (-1 once closed).
IpAddress lo #= IpAddress.loopbackV4();
SocketAddress bindAddr #= SocketAddress.of(#lo, 0);
TcpListener listener #= TcpListener.bind(bindAddr);
int32 port = listener.boundPort(); // kernel-assigned ephemeral port
TcpStream conn #= listener.accept(); // blocks until a client connects
conn.close();
listener.close();
Methods
| Signature | |
|---|---|
static #TcpListener bind(SocketAddress addr) ⚑ | Bind a fresh TCP listening socket to addr and start listening with the default backlog (128) |
#TcpStream accept() | Block until a client connects, then return the accepted connection |
int32 acceptFd() | The fd-level half of accept: block for one connection and return its raw descriptor (>= 0), or throw on failure |
#TcpStream acceptAsync() | Async accept — park the fiber (not the carrier) until a connection is pending; errors raise the mapped NetException subtype |
int32 boundPort() | The kernel-assigned local port (resolves the ephemeral port for a :0 bind) |
#SocketAddress localAddress() | The bound local endpoint; currently a placeholder that returns the IPv4 wildcard 0.0.0.0:0 — use boundPort for the real port |
void close() | Close the listening socket; idempotent |
⚑ = @EntryPoint
See also
- Tour: NetDemo
- Source:
runtime/src/cajeta/io/net/TcpListener.cajeta - TcpStream — the accepted connection; Server — the accept-loop core built on this; TlsListener — the TLS-terminating counterpart