Capy-Bearer Documentation

socket_connect

lib call

Capy

function socket_connect(host : string, port : s32, timeout : s32 = 0) u64

Description

Use socket_connect to open a socket to an IPv4 address and port. Pass a nonzero handle to the socket functions. timeout is in seconds and bounds the connect; 0 means the rest of the request's time budget. The budget always applies, so a long timeout cannot outlive the request.

Return Values

Socket handle, or zero when the connection fails.

Example

Capy

var handle := socket_connect("127.0.0.1", 80)
print(handle, "\n")

Output

1