Function connectTcpOptions [src]

Prototype

pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcpError!*Connection

Parameters

client: *Clientoptions: ConnectTcpOptions

Possible Errors

ConnectionRefused
ConnectionResetByPeer
ConnectionTimedOut
HostLacksNetworkAddresses
NameServerFailure
NetworkUnreachable
OutOfMemory Error
TemporaryNameServerFailure
TlsInitializationFailed
UnexpectedConnectFailure
UnknownHostName

Source

pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcpError!*Connection { const host = options.host; const port = options.port; const protocol = options.protocol; const proxied_host = options.proxied_host orelse host; const proxied_port = options.proxied_port orelse port; if (client.connection_pool.findConnection(.{ .host = proxied_host, .port = proxied_port, .protocol = protocol, })) |conn| return conn; const stream = net.tcpConnectToHost(client.allocator, host, port) catch |err| switch (err) { error.ConnectionRefused => return error.ConnectionRefused, error.NetworkUnreachable => return error.NetworkUnreachable, error.ConnectionTimedOut => return error.ConnectionTimedOut, error.ConnectionResetByPeer => return error.ConnectionResetByPeer, error.TemporaryNameServerFailure => return error.TemporaryNameServerFailure, error.NameServerFailure => return error.NameServerFailure, error.UnknownHostName => return error.UnknownHostName, error.HostLacksNetworkAddresses => return error.HostLacksNetworkAddresses, else => return error.UnexpectedConnectFailure, }; errdefer stream.close(); switch (protocol) { .tls => { if (disable_tls) return error.TlsInitializationFailed; const tc = try Connection.Tls.create(client, proxied_host, proxied_port, stream); client.connection_pool.addUsed(&tc.connection); return &tc.connection; }, .plain => { const pc = try Connection.Plain.create(client, proxied_host, proxied_port, stream); client.connection_pool.addUsed(&pc.connection); return &pc.connection; }, } }