Method Stdio.File()->connect()
- Method connect
variantintconnect(stringhost,int(0..)|stringport)
variantintconnect(stringhost,int(0..)|stringport,stringclient,int(0..)|stringclient_port)
variantstringconnect(stringhost,int(0..)|stringport,stringdata)
variantstringconnect(stringhost,int(0..)|stringport,int(0..0)|stringclient,int(0..)|stringclient_port,stringdata)- 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.
The
hostargument is the hostname or IP number of the remote machine.A local IP and port can be explicitly bound by specifying
clientandclient_port.If the
dataargument is included the socket will use TCP_FAST_OPEN if posible. In this mode the the function will return the part of the data that has not been sent to the remote server yet instead of 1 (you will have to use write to send this data).Note that TCP_FAST_OPEN requires server support, the connection might fail even though the remote server exists. It might be advicable to retry without TCP_FAST_OPEN (and remember this fact)
- Returns
This function returns 1 or the remaining
datafor success, 0 otherwise.- Note
In nonblocking mode
0(zero) may be returned and errno() set toEWOULDBLOCKorWSAEWOULDBLOCK.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