WebTcpipListen Function

Action

Creates a listener socket on a specified port and returns a handle to that socket.

Include file

WebAPI.bdh

Syntax

WebTcpipListen( inout hTcpipListen : number
                in nPort           : number ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hTcpipListen Variable receiving a handle to the listener socket.
nPort Specifies the port number to listen at.

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 connections
    WebTcpipShutdown(hTcpip);
    WebTcpipShutdown(hListen);
  end TServer;