WebTcpipSetOptions Function

Action

Sets a TCP/IP connection’s specific options.

Include file

WebAPI.bdh

Syntax

WebTcpipSetOptions(    in hWeb           : number,
                       in nOptions       : number,
                       in bEnable        : boolean optional,
                       in sAutoReplyData : string optional ): boolean;

Return value

  • true if the operation succeeded

  • false otherwise

Parameter Description
hWeb Valid handle to a Web connection created by WebTcpipConnect.
nOptions

Connection behavior settings, which may be any bitwise combination of the following:

  • TELNET_MODEOPT_FILTER_NOPS := 0x0001;

  • TELNET_MODEOPT_AUTOANSWER_TM := 0x0002;

  • TELNET_MODEOPT_FILTER_TM := 0x0004;

  • TELNET_MODEOPT_RFC_1576 := 0x0007;

  • TELNET_MODEOPT_AUTO_RECV := 0x0018;

  • TELNET_MODEOPT_SYNC := 0x0020;

  • TELNET_MODEOPT_3270E_AUTO_REPLY := 0x0040;

See WebTcpipSetTelnetMode for details.

bEnable In case this parameter is present, a single option can be turned on/off without affecting the other options (optional). In case this parameter is omitted, the nOptions parameter sets all available options according to its bitmask.
sAutoReplyData In combination with TELNET_MODEOPT_3270E_AUTO_REPLY an auto-reply string to the server may be specified here, which is by default a NULL byte - 0x0 (optional).

Example

dcltrans
  transaction TInit
  begin
    StrSetHostCP(28591); // 28591
(ISO 8859-1 Latin I)
  end TInit;   transaction   TMain
  var
    hWeb0     : number;
    sBuffer   : string;
    sBoundary : string;
    nOption   : number;
  begin
    WebTcpipConnect(hWeb0, "My.TelnetHost.IP", WEB_PORT_TELNET);
    WebTcpipSetTelnetMode(hWeb0, TERMINAL_TYPE_ANSI, 80, 24, true,
      TELNET_MODEOPT_AUTO_RECV);
    WebTcpipGetOptions(hWeb0, nOption);
    if nOption <> TELNET_MODEOPT_RFC_1576 then
      WebTcpipSetOptions(hWeb0, TELNET_MODEOPT_RFC_1576);
    end;
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TerminalType);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TerminalSpeed);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_XDisplayLocation);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_NewEnvironment);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_TerminalType);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_TerminalSpeed);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_XDisplayLocation);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_NewEnvironment);
    WebTelnetRecvSubNegotiation(hWeb0, TELNET_OPT_TerminalType);
    WebTelnetSendTerminalType(hWeb0, "vt100");
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_SuppressGoAhead);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_Echo);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_NegotiateWindowSize);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_Status);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_RemoteFlowControl);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_SuppressGoAhead);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_Echo);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_NegotiateWindowSize);
    WebTelnetSendSubNegotiation(hWeb0, TELNET_OPT_NegotiateWindowSize, "\h00500018");
    WebTelnetSendCommand(hWeb0, TELNET_CMD_DONT, TELNET_OPT_Status);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_RemoteFlowControl);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_Echo);
    WebTcpipGetPacketBoundary(hWeb0, sBoundary);    
    WebTcpipRecvPacketsUntilData(hWeb0, "login: ");
    WebTelnetTypeKeys(hWeb0, StrToHostCP("leo"), 359.3, TELNET_FLAG_CASE_SENSITIVE);
    WebTcpipSendBin(hWeb0, "\h0D00");
    WebTcpipRecvExact(hWeb0, NULL, 390);
    WebTcpipSetPacketBoundary(hWeb0, sBoundary);
    WebTcpipRecvUntilIdle(hWeb0, NULL, 5000);
    WebTcpipSendBin(hWeb0, "\h0D000D0A");
    WebTcpipRecvPackets(hWeb0, NULL, 3);
    WebTcpipSendBin(hWeb0, "\h0D00");
    WebTcpipSendPacket(hWeb0, StrToHostCP("8") + "\h0D00");
    WebTcpipRecvClose(hWeb0, NULL);
    WebTcpipShutdown(hWeb0);
  end TMain;