hi,
i want to know how to manage the socket on C++ BuilderClient/server with TClientSocket and TServerSocket and How Manages the OnClientRead events and the method for sends text.
hi,
i want to know how to manage the socket on C++ BuilderClient/server with TClientSocket and TServerSocket and How Manages the OnClientRead events and the method for sends text.
One Starts with the Server application:
To start your C++ Builder (I have the version 2007)
To create a new “Receiving” project
In the pallet component to add one
TEdit
TButton “the Caption title is Fermer”
TServerSocket
Double Clicks on the window
void __fastcall TForm1:: FormCreate (TObject *Sender)
{
ServerSocket1->Port = 23;
ServerSocket1->Active = True;
}
//--
On the events of the mitre Objet Inspector, double clicks on the case of OnClose and put this code:
//---------------------------------------------------------------------------
void __fastcall TForm1:: FormClose (TObject *Sender, TCloseAction &Action)
{
ServerSocket1->Active = False;
}
//------
On the Card (Form1) click on ServerSocket1 control
On the events of the mitre Objet inspector, double clicks on the case of OnClientRead
Put this code:
void __fastcall TForm1:: ServerSocket1ClientRead (TObject *Sender,
TCustomWinSocket *Socket)
{
Edit1->Clear ();
Edit1->Text = Socket->ReceiveText ();
}
//-
To record the project
Maintaining the Customer:
To create a new project “Waiter”
To add TButton of the caption: Send (sent)
To add ClientSocket
And TEdit
Double clicks on the window and to add this code:
void __fastcall TForm1:: FormCreate (TObject *Sender)
{
ClientSocket1->Port = 23;
ClientSocket1->Host = “Address IP HERE”;
ClientSocket1->Active = True;
}
//-
And In OnClose add this code:
//---------------------------------------------------------------------------
void __fastcall TForm1:: FormClose (TObject *Sender, TCloseAction &Action)
{
ClientSocket1->Active = False;
}
//-
On the card To click twice on the short prop “Send”
Add this code:
void __fastcall TForm1:: Button1Click (TObject *Sender)
{
yew (ClientSocket1->Active)
ClientSocket1->Socket->SendText (Edit1->Text);
}
//-
Recorded the project and carried out it.
hi,
Thank you, for instruction......
Bookmarks