| Extracted from Pike v7.8 release 700 at 2013-06-08.

[Top]
Stdio
Stdio.File

# Method Stdio.File()->connect()

Method connect

  `int(0..1) connect(string dest_addr, int dest_port)`
  `int(0..1) connect(string dest_addr, int dest_port, string src_addr, int src_port)`

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.

Returns

  Returns `1` 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.

Method connect

  `int connect(string host, int|string port, void|string client, void|int|string client_port)`

Description

  This function connects a socket previously created with open_socket() to a remote socket through TCP/IP. The host argument is the hostname or IP number of the remote machine. A local IP and port can be explicitly bound by specifying client and client_port .

Returns

  This function returns 1 for success, 0 otherwise.

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. In nonblocking mode you need to wait for a write or close callback before you know if the connection failed or not.

See also

  query_address() , async_connect() , connect_unix()