feature. See also
. The project being documented here (as the example) is the Zig library itself.
Client.connectTcpOptions
pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcpError!*Connection
File
Code
pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcpError!*Connection {
const io = client.io;
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 (try client.connection_pool.findConnection(io, .{
.host = proxied_host,
.port = proxied_port,
.protocol = protocol,
})) |conn| return conn;
var stream = try host.connect(io, port, .{ .mode = .stream });
errdefer stream.close(io);
switch (protocol) {
.tls => {
if (disable_tls) return error.TlsInitializationFailed;
const tc = Connection.Tls.create(client, proxied_host, proxied_port, stream) catch |err| switch (err) {
error.OutOfMemory => |e| return e,
error.Unexpected => |e| return e,
error.Canceled => |e| return e,
else => return error.TlsInitializationFailed,
};
errdefer tc.destroy();
try client.connection_pool.addUsed(io, &tc.connection);
return &tc.connection;
},
.plain => {
const pc = try Connection.Plain.create(client, proxied_host, proxied_port, stream);
errdefer pc.destroy();
try client.connection_pool.addUsed(io, &pc.connection);
return &pc.connection;
},
}
}