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 standard library.
std › http › Client › connectTcpOptions Public Function connectTcpOptions Doc Source 1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483 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 ;
},
}
}