HB_INETCONNECT()
Connect a socket to a remote server by IP address or name
Syntax
HB_INETCONNECT( <cAddress>, <nPort> ) -> SOCKET HB_INETCONNECT( <cAddress>, <nPort>, <socket> ) -> NIL
Arguments
<cAddress>
<nPort>
<socket>
Returns
(First form) INET socket
(Second form has no return value)
Description
Connects to a remote server described by cAddress, that can be in quad dot notation (e.g. “192.168.1.1”) or in DNS name (e.g. “www.xharbour.org”), using the desired port.
hb_InetConnect uses “gethostbyname” C system call to find the network address of the specified server; this means that this call is an hybrid function doing both a DNS scan and a TCP/IP connection. hb_InetConnect is not thread safe, and the program must take care that two hb_InetConnect functions are never called at the same moment from two different threads (or that hb_InetGetHosts is not called in the same moment as an hb_InetConnect).
The second version of this function accepts a pre-built socket as a parameter. This allows to kill asyncronously a thread waiting for hb_InetConnect to connect, and then cleaning up the leftover socket data. Also, it is possible to give timeout to the given SOCKET, but this timeout will be used only in the connection phase, after that the network address resolution is completed. Use GetHosts() and hb_InetConnectIP for a finer timeout control. On error, the error of the returned socket is set. The error could be due to unavailable name resolving service, host name not valid, host address not reachable and host reachable but port not open.
Compliance
Harbour
Pingback: Harbour All Functions – H | Viva Clipper !
Pingback: Harbour inet Functions | Viva Clipper !
Pingback: Harbour RG Summary | Viva Clipper !