WebTcpipRecvExact Function

Action

Receives an exact number of data bytes from a remote host unless an error occurs or the connection is closed by the server.

Include file

WebAPI.bdh

Syntax

WebTcpipRecvExact( in  hWeb      : number,
                   out sData     : string optional,
                   in  nData     : number optional,
                   out nReceived : number optional ): boolean;

Return value

  • true if the exact number of bytes was received

  • false otherwise

Parameter Description
hWeb Valid handle to a Web connection that was created by WebTcpipConnect
sData Buffer to store the received data (optional). If this parameter is set to NULL, internal buffers are used for retrieval. In this case, the received data cannot be parsed
nData

Amount of data bytes to receive (optional). Make sure to set

nData <= size of sData

nReceived Parameter that receives the actual amount of data received from the server (optional)

Example

dcltrans
  transaction TWeb
  var
    hWeb      : number;
    sHdr      : string;
    sSize     : string(20);
    nReceived : number;
  begin
    WebTcpipConnect(hWeb, "lab3", 80);
    sHdr := "GET /file5k.html HTTP/1.1\r\n"
            "Host: lab3\r\n\r\n";
    // send HTTP  request header
    WebTcpipSend(hWeb, sHdr);
    // receive HTTP response header
    WebTcpipRecvUntil(hWeb, sHdr, STRING_COMPLETE, nReceived, "\r\n\r\n");
    // receive document
    StrSearchDelimited(sSize, STRING_COMPLETE, sHdr,
                        "Content-Length: ", 1, "\r\n",
                        1, STR_SEARCH_FIRST);
    WebTcpipRecvExact(hWeb, NULL, number(sSize));
    // reset the persistent connection
    WebTcpipShutdown(hWeb, WEB_SHUTDOWN_RESET);
  end TWeb;

Sample scripts

WebTcpipHttp01.bdf, WebTcpipImap401.bdf