feature. See also
. The project being documented here (as the example) is the Zig library itself.
Uring.bind
fn bind(
ev: *Evented,
cancel_region: *CancelRegion,
socket_fd: fd_t,
addr: *const linux.sockaddr,
addr_len: linux.socklen_t,
) !void
File
Code
fn bind(
ev: *Evented,
cancel_region: *CancelRegion,
socket_fd: fd_t,
addr: *const linux.sockaddr,
addr_len: linux.socklen_t,
) !void {
while (true) {
const thread = try cancel_region.awaitIoUring();
thread.enqueue().* = .{
.opcode = .BIND,
.flags = 0,
.ioprio = 0,
.fd = socket_fd,
.off = addr_len,
.addr = @intFromPtr(addr),
.len = 0,
.rw_flags = 0,
.user_data = @intFromPtr(cancel_region.fiber),
.buf_index = 0,
.personality = 0,
.splice_fd_in = 0,
.addr3 = 0,
.resv = 0,
};
ev.yield(null, .nothing);
switch (cancel_region.errno()) {
.SUCCESS => return,
.INTR, .CANCELED => {},
.ADDRINUSE => return error.AddressInUse,
.BADF => |err| return errnoBug(err),
.INVAL => |err| return errnoBug(err),
.NOTSOCK => |err| return errnoBug(err),
.AFNOSUPPORT => return error.AddressFamilyUnsupported,
.ADDRNOTAVAIL => return error.AddressUnavailable,
.FAULT => |err| return errnoBug(err),
.NOMEM => return error.SystemResources,
else => |err| return unexpectedErrno(err),
}
}
}