Notes binary data like VT100 escape sequences to be verified as received on next sending operation in a Telnet connection. This asynchronous function helps building more robust scripts because some Telnet servers mix Telnet command sequences with regular output data. The received data itself will be prepended to data in the order it was received in the next subsequently received function call.
WebAPI.bdh
WebTelnetSyncData( in hWeb : number, in sData : string ) : boolean;
true if the operation was successful
false otherwise
Parameter | Description |
---|---|
hWeb | Valid handle to a Web connection created by WebTcpipConnect and set to Telnet mode using WebTcpipSetTelnetMode. The connection must be in “Sync-Mode” (set option TELNET_MODEOPT_SYNC). |
sData | Binary data string expected from the server. |
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_RFC_1576 | TELNET_MODEOPT_SYNC); WebTelnetSetTerminalConfigString(hWeb0, "AutoWrap=false 8Bit=false Tab=9*"); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TerminalType); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_NegotiateWindowSize); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_RemoteFlowControl); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_SendLocation); WebTelnetSyncCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_Echo); WebTelnetSyncCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_SuppressGoAhead); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TerminalSpeed); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_XDisplayLocation); // commands above are verified here WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_TerminalType); WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_NegotiateWindowSize); WebTelnetSendSubNegotiation(hWeb0, TELNET_OPT_NegotiateWindowSize, "\h00500018"); // •P•• WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_RemoteFlowControl); WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_SendLocation); WebTelnetSendCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_Echo); WebTelnetSendCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_SuppressGoAhead); WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_TerminalSpeed); WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_XDisplayLocation); WebTelnetSyncSubNegotiation(hWeb0, TELNET_OPT_TerminalType); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DONT, TELNET_OPT_RemoteFlowControl); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DONT, TELNET_OPT_SendLocation); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DONT, TELNET_OPT_TerminalSpeed); WebTelnetSyncCommand(hWeb0, TELNET_CMD_DONT, TELNET_OPT_XDisplayLocation); // sync commands above are verified here WebTelnetSendTerminalType(hWeb0, "vt100"); WebTelnetTypeKeys(hWeb0, StrToHostCP("guest") + WEB_CRNULL, 294.1, TELNET_FLAG_CASE_SENSITIVE); WebTelnetSyncData(hWeb0, "\h0D0A1B5B63"); // •••[c // sync data above is verified here WebTcpipSend(hWeb0, "\h1B5B3F313B3063"); // •[?1;0c WebTelnetSyncData(hWeb0, "\h5B366E1B38"); // [6n•8 // sync data above is verified here WebTcpipSend(hWeb0, "\h1B5B32343B383052"); // •[24;80R // received sync data is prepended to received data here WebTcpipScreenRecvPacketsUntilCursor(hWeb0, 40, 23); WebTcpipShutdown(hWeb0); end TMain;