xHarbour Reference Documentation > Function Reference |
Waits for an incoming connection on a server side socket.
INetAccept( <pServerSocket> ) --> pClientSocket
The function returns a socket to a connected client process.
Function INetAccept() is the only function available to establish a connection between the current process (server side) and a remote process (client side) that wants to connect to the server process. The socket <pServerSocket> must be created with function INetServer(). When passed to INetAccept(), the function does not return until a remote client process requests a connection. For this reason, it is recommended to set a timeout value with INetSetTimeout() in order to stop listening on the server socket periodically and react to user input in the server process.
An alternative is to use a separate thread that calls INetAccept() while the main thread is processing user input. Note that INetAccept() returns when <pServerSocket> is closed with INetClose(). That is, if INetAccept() is called in a separate thread, this thread is blocked until a connection request from outside is detected. If the main thread closes the server socket while a second thread waits for a connection request, INectAccept() returns with an socket error, and the second thread can terminate.
The socket returned from INetAccept() can be used to exchange data between the current process and a remote process using INetRecv() and INetSend().
An example for a complete client/server communication is provided with function INetServer().
See also: | INetConnect(), INetInit(), INetRecv(), INetSend(), INetServer(), INetSetTimeout() |
Category: | Internet functions , Sockets functions , xHarbour extensions |
Source: | vm\INet.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
http://www.xHarbour.com