tcpConnectToAddress
Function parameters
Parameters
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 tcpConnectToAddress(address: Address) TcpConnectToAddressError!Stream {
const nonblock = 0;
const sock_flags = posix.SOCK.STREAM | nonblock |
(if (native_os == .windows) 0 else posix.SOCK.CLOEXEC);
const sockfd = try posix.socket(address.any.family, sock_flags, posix.IPPROTO.TCP);
errdefer Stream.close(.{ .handle = sockfd });
try posix.connect(sockfd, &address.any, address.getOsSockLen());
return Stream{ .handle = sockfd };
}