Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › Io › Threaded › netShutdownPosix Private Function netShutdownPosix Doc Source Private Function std.Io.Threaded.netShutdownPosix
fn netShutdownPosix (userdata : ?*anyopaque , handle : net .Socket .Handle , how : net .ShutdownHow ) net .ShutdownError !void Params userdata : ?*anyopaque handle : net .Socket .Handle how : net .ShutdownHow File Io/Threaded.zig: 13508
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538 fn netShutdownPosix (userdata : ?*anyopaque , handle : net .Socket .Handle , how : net .ShutdownHow ) net .ShutdownError !void {
if (!have_networking ) return error .NetworkDown ;
const t : *Threaded = @ptrCast (@alignCast (userdata ));
_ = t ;
const posix_how : i32 = switch (how ) {
.recv => posix .SHUT .RD ,
.send => posix .SHUT .WR ,
.both => posix .SHUT .RDWR ,
};
const syscall : Syscall = try .start ();
while (true ) {
switch (posix .errno (posix .system .shutdown (handle , posix_how ))) {
.SUCCESS => return syscall .finish (),
.INTR => {
try syscall .checkCancel ();
continue ;
},
else => |e | {
syscall .finish ();
switch (e ) {
.BADF , .NOTSOCK , .INVAL => |err | return errnoBug (err ),
.NOTCONN => return error .SocketUnconnected ,
.NOBUFS => return error .SystemResources ,
else => |err | return posix .unexpectedErrno (err ),
}
},
}
}
}