WebTcpipSetTelnetMode Function


Switches pure TCP/IP connection mode to Telnet connection mode. Telnet connections allow several Telnet protocol-specific BDL operations for terminal emulation support.

Include file



WebTcpipSetTelnetMode(    in hWeb        : number,
                          in sRendererId : string,
                          in nCols       : number optional,
                          in nRows       : number optional,
                          in bUseColor   : number optional,
                          in nOptions    : number optional ): boolean;

Return value

  • true if the operation was successful

  • false otherwise

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

ID of a renderer that should be used when handling high-level Telnet functions. Currently defined rendererIds are:

  • TELNET_RENDERER_3270: Connection drives a 3270 terminal service renderer.

  • TELNET_RENDERER_5250: Connection drives a 5250 terminal service renderer.

  • TELNET_RENDERER_ANSI: Connection drives an ANSI terminal service renderer (VT100 Terminal Client Series).

  • TELNET_RENDERER_VT200: Connection drives an ANSI terminal service renderer (VT200 Terminal Client Series).

nCols Rendered screen width (optional). Default (0) value is read from profile settings.
nRows Rendered screen height (optional). Default (0) value is read from profile settings.
bUseColors Specifies if rendered screen should be displayed in color (optional). Default is false.

Specific Telnet service protocol option (optional). Currently the following options are available and can be ORed (+ operator):

  • TELNET_MODEOPT_FILTER_NOPS: According to RFC 1576, a host server periodically sends an IAC NOP sequence to test its connection status. These operations may be auto-filtered before getting to further BDL operations because in most cases they are sent periodically and not in the same command sequence order.

  • TELNET_MODEOPT_AUTOANSWER_TM: According to RFC 1576, a host server may periodically send an IAC DO TimingMark sequence, awaiting a IAC WONT TimingMark response, for checking availability of the telnet client. Because these signals are sent periodically and not in a defined sequence order, they may be filtered and auto-answered in the background by the connection itself.


  • TELNET_MODEOPT_AUTO_RECV: For writing more robust scripts for telnet servers sending time-dependent dynamic information (e.g., server time), each send operation empties the receive buffer.

  • TELNET_MODEOPT_SYNC: For writing more robust scripts for telnet servers sending negotiating Telnet options in a non- or partly deterministic manner, expected commands, option negotiation or data may be noted. All expected data is then verified at next sending function and prepended to the data of the next receiving function. See WebTelnetSyncCommand, WebTelnetSyncSubNegotiation, and WebTelnetSyncData for details.

  • TELNET_MODEOPT_3270E_AUTO_REPLY: Enable this option for writing more robust scripts for Telnet servers using the 3270E protocol. Such servers require a client confirmation after each response, which may be individually set using WebTcpipSetOptions.


  transaction TInit
    StrSetHostCP(28591); // 28591 (ISO 8859-1 Latin I)
  end TInit;   
transaction TMain
    hWeb0     : number;
    sBuffer   : string;
    sBoundary : string;
    nOption   : number;
    WebTcpipConnect(hWeb0, "My.TelnetHost.IP", WEB_PORT_TELNET);
    WebTcpipSetTelnetMode(hWeb0, TERMINAL_TYPE_ANSI, 80, 24, true,

    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);
  end TMain;