Avaliação do Usuário

Estrela inativaEstrela inativaEstrela inativaEstrela inativaEstrela inativa


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 hb_inetGetHosts() 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.

This is Harbour specific