accept
Blocks until a client connects to the server. The returned Connection has
an open stream.
Function parameters
Parameters
- s:*Server
Type definitions in this namespace
Types
Functions in this namespace
Functions
- tcpConnectToHost
- All memory allocated with `allocator` will be freed before this function returns.
- getAddressList
- Call `AddressList.deinit` on the result.
Error sets in this namespace
Error Sets
= switch (native_os) { .windows => builtin.os.version_range.windows.isAtLeast(.win10_rs4) orelse false, .wasi => false, else => true, }
Values
- has_unix_sockets
- = switch (native_os) { .windows => builtin.os.version_range.windows.isAtLeast(.win10_rs4) orelse false, .wasi => false, else => true, }
Source
Implementation
pub fn accept(s: *Server) AcceptError!Connection {
var accepted_addr: Address = undefined;
var addr_len: posix.socklen_t = @sizeOf(Address);
const fd = try posix.accept(s.stream.handle, &accepted_addr.any, &addr_len, posix.SOCK.CLOEXEC);
return .{
.stream = .{ .handle = fd },
.address = accepted_addr,
};
}