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 library itself.
Zig › std/ › Io/ › Threaded.zig › netBindIpPosix
netBindIpPosix
Threaded.netBindIpPosix
fn netBindIpPosix (
userdata : ?*anyopaque ,
address : *const IpAddress ,
options : IpAddress .BindOptions ,
) IpAddress .BindError !net .Socket
File
Code
fn netBindIpPosix (
userdata : ?*anyopaque ,
address : *const IpAddress ,
options : IpAddress .BindOptions ,
) IpAddress .BindError !net .Socket {
if (!have_networking ) return error .NetworkDown ;
const t : *Threaded = @ptrCast (@alignCast (userdata ));
_ = t ;
const family = posixAddressFamily (address );
const socket_fd = try openSocketPosix (family , options );
errdefer closeFd (socket_fd );
var storage : PosixAddress = undefined ;
var addr_len = addressToPosix (address , &storage );
try posixBind (socket_fd , &storage .any , addr_len );
if (options .allow_broadcast ) try setSocketOptionPosix (socket_fd , std .posix .SOL .SOCKET , std .posix .SO .BROADCAST , 1 );
try posixGetSockName (socket_fd , &storage .any , &addr_len );
return .{ .handle = socket_fd , .address = addressFromPosix (&storage ) };
}