Method _Stdio.Fd()->connect()
- Method
connect
int(-1..1)connect(string(8bit)dest_addr,intdest_port)
int(-1..1)connect(string(8bit)dest_addr,intdest_port,string(8bit)src_addr,intsrc_port)
string(8bit)|int(-1..0)connect(string(8bit)dest_addr,intdest_port,string(8bit)|voidsrc_addr,int|voidsrc_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
dataargument 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 one of
string(8bit)datathat did not fit into the initial connection packet. Note that the connection may not have been established yet.int(0)Returns
0on (synchronous) connection failure.int(1)Returns
1if there was nodatato send.int(-1)Returns
-1if the connection has not yet been established. Use eg poke() or query_address() to wait or check for when the connection completes.- Note
Note that in versions of Pike prior to 9.0
1was returned also in the not yet established case.Note that
-1may be returned also for sockets in blocking mode if the connect(3N) system call was interrupted.- See also