//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
ServerSocket1->Active = true ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientConnect(TObject *Sender,
TCustomWinSocket *Socket)
{
// Application->MessageBoxA("un client arrive", NULL ,MB_OK ) ;
StatusBar1->SimpleText="Connexion d'un client" ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientDisconnect(TObject *Sender,
TCustomWinSocket *Socket)
{
// Application->MessageBoxA("un client part", NULL ,MB_OK ) ;
StatusBar1->SimpleText="Le client a interrompu la liaison" ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
AnsiString recept ;
StatusBar1->SimpleText="Dialogue en cours" ;
recept = Socket->ReceiveText() ;
Memo1->Lines->Add(recept) ;
Socket->SendText("Reçu:" + recept + "par " + "-" + Socket->LocalAddress + "-" +
Socket->LocalHost );
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
ServerSocket1->Active = false ;
}
//---------------------------------------------------------------------------