VTClientSession.cpp
上传用户:wsk323
上传日期:2007-01-05
资源大小:403k
文件大小:5k
- /*---------------------------------------------------------------------------
- Copyright: E. Brady Trexler
- Creation: March 1998
- Description: VTClientSession -- a VCL form using a TnCnx component from
- F. Piette. Basically, this class reads data coming from
- the TnCnx socket.
- Legal issues: Copyright (C) 1998 by E. Brady Trexler
- This software is provided 'as-is', without any express or
- implied warranty. In no event will the author be held liable
- for any damages arising from the use of this software.
- Permission is granted to anyone to use this software for any
- purpose, excluding commercial applications, and to alter it
- and redistribute it freely, subject to the following
- restrictions:
- 1. The origin of this software must not be misrepresented,
- you must not claim that you wrote the original software.
- If you use this software in a product, an acknowledgment
- in the product documentation would be appreciated but is
- not required.
- 2. Altered source versions must be plainly marked as such, and
- must not be misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source
- distribution.
- Updates:
- ---------------------------------------------------------------------------*/
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include <stdio.h>
- #include <conio.h>
- #include "VTClientSession.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "TnCnx"
- #pragma resource "*.dfm"
- TVTClient *VTClient;
- //---------------------------------------------------------------------------
- __fastcall TVTClient::TVTClient(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TnCnxDataAvailable(TTnCnx *Sender, PChar Buffer,
- int Len)
- {
- // Insert code here
- DWORD dwWritten;
- WriteFile(hSaveStdout, Buffer, Len, &dwWritten, NULL);
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TnCnxDisplay(TTnCnx *Sender, AnsiString Str)
- {
- // Insert code here
- DWORD dwWritten;
- Str += "rn";
- char *Buffer = Str.c_str();
- int Len = strlen(Buffer);
- WriteFile(hSaveStdout, Buffer, Len, &dwWritten, NULL);
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TnCnxEndOfRecord(TObject *Sender)
- {
- // Insert code here
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TnCnxLocalEcho(TObject *Sender)
- {
- // Insert code here
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TnCnxSendLoc(TObject *Sender)
- {
- // Insert code here
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TnCnxSessionClosed(TTnCnx *Sender, WORD Error)
- {
- // Insert code here
- DWORD dwWritten;
- char Buffer[256];
- sprintf(Buffer, "rn<<<Session ended by remote host>>>rn");
- int Len = strlen(Buffer);
- WriteFile(hSaveStdout, Buffer, Len, &dwWritten, NULL);
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TnCnxSessionConnected(TTnCnx *Sender, WORD Error)
- {
- // Insert code here
- DWORD dwWritten;
- char Buffer[256];
- sprintf(Buffer,"rn<<<Session accepted by remote host>>>rn");
- int Len = strlen(Buffer);
- WriteFile(hSaveStdout, Buffer, Len, &dwWritten, NULL);
- TimeOutTimer->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TnCnxTermType(TObject *Sender)
- {
- // Insert code here
- }
- //---------------------------------------------------------------------------
- // Process each character received to do minimal line editing
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::ProcessChar(char Ch)
- {
- // Insert code here
- }
- //---------------------------------------------------------------------------
- // This is the command line interpreter.
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::CommandInterpreter()
- {
- // Insert code here
- }
- //---------------------------------------------------------------------------
- void __fastcall TVTClient::TimeOutTimerTimer(TObject *Sender)
- {
- if (!TnCnx->IsConnected()){
- Close();
- DWORD dwWritten;
- char Buffer[256];
- sprintf(Buffer,"rnrnServer unavailable...rnrn
- ......Connection refused.rn");
- int Len = strlen(Buffer);
- WriteFile(hSaveStdout, Buffer, Len, &dwWritten, NULL);
- }
- }
- //---------------------------------------------------------------------------