feature. See also
. The project being documented here (as the example) is the Zig library itself.
Threaded.posixSocketModeProtocol
pub fn posixSocketModeProtocol(family: posix.sa_family_t, mode: net.Socket.Mode, protocol: ?net.Protocol) !struct
File
Code
pub fn posixSocketModeProtocol(family: posix.sa_family_t, mode: net.Socket.Mode, protocol: ?net.Protocol) !struct { u32, u32 } {
return .{
switch (mode) {
.stream => posix.SOCK.STREAM,
.dgram => posix.SOCK.DGRAM,
.seqpacket => posix.SOCK.SEQPACKET,
.raw => posix.SOCK.RAW,
.rdm => if (@hasDecl(posix.SOCK, "RDM")) posix.SOCK.RDM else return error.OptionUnsupported,
},
if (protocol) |p| @backingInt(p) else if (is_windows) switch (family) {
posix.AF.UNIX => switch (mode) {
.stream => 0,
else => return error.ProtocolUnsupportedByAddressFamily,
},
posix.AF.INET, posix.AF.INET6 => @backingInt(@as(net.Protocol, switch (mode) {
.stream => .tcp,
.dgram => .udp,
else => return error.ProtocolUnsupportedByAddressFamily,
})),
else => return error.ProtocolUnsupportedByAddressFamily,
} else 0,
};
}