Pike v8.1 release 6

Method Stdio.Fd()->connect()


Method connect

bool connect(string dest_addr, int dest_port)
bool connect(string dest_addr, int dest_port, string src_addr, int src_port)
string(8bit)|int(0..0) connect(string dest_addr, int dest_port, string|int(0..0) src_addr, int|int(0..0) src_port, string(8bit) data)

Description

Open a TCP/IP connection to the specified destination.

In nonblocking mode, success is indicated with the write-callback, and failure with the close-callback or the read_oob-callback.

If the data argument is included the socket will use TCP_FAST_OPEN if available, if not the data will not be sent. In the data case the function either returns the data that has not been sent (only one packet can be sent with this option) or 0 if the connection failed immediately.

Returns

Returns 1 or the remaining data on success, and 0 on failure.

Note

In nonblocking mode 0 (zero) may be returned and errno() set to EWOULDBLOCK or WSAEWOULDBLOCK. This should not be regarded as a connection failure.