Connect a socket to a remote server by IP address or name


      HB_INETCONNECT( <cAddress>, <nPort> ) -> SOCKET

      HB_INETCONNECT( <cAddress>, <nPort>, <socket> ) -> NIL






(First form) INET socket

(Second form has no return value)


Connects to a remote server described by cAddress, that can be in quad dot notation (e.g. “”) 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.



3 responses to “hb_inetConnect()

  1. Pingback: Harbour All Functions – H | Viva Clipper !

  2. Pingback: Harbour inet Functions | Viva Clipper !

  3. Pingback: Harbour RG Summary | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.