WebTcpipAccept Function

Action

Listens for a connection to be established to a listener socket and accepts the connection. Before you can use this function, you have to create a valid connection handle with the WebTcpipListen function. The WebTcpipAccept function blocks the called until a connection is established.

Include file

WebAPI.bdh

Syntax

WebTcpipAccept( in  hTcpipListen : number
                out hTcpip       : number): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hTcpipListen Valid handle to a connection created with the WebTcpipListen function.
hTcpip Variable receiving the handle to the accepted connection.

Example

dcltrans
  transaction TServer
  var
    hTcpip, hListen, nRecv : number;
    sData                  : string;
  begin
    // start listening on port 88
    WebTcpipListen(hListen, 88);
    // accept client request
    WebTcpipAccept(hListen, hTcpip);
    // receive data from the client
    WebTcpipRecvUntil(hTcpip, sData, STRING_COMPLETE, nRecv, "\r\n\r\n", 4);
    // process the client’s request
    // close the connections
    WebTcpipShutdown(hTcpip);
    WebTcpipShutdown(hListen);
  end TServer;