Article View: borland.public.cppbuilder.nativeapi
Article #9017Re: Send msg to another pc over network
From: Mentor
Date: Tue, 17 Aug 2004 15:38
Date: Tue, 17 Aug 2004 15:38
47 lines
2275 bytes
2275 bytes
>Don't reinvent the wheel :)
Haha :) I already reinvented my pal.I dropped a TMemo and TServerSocket to my form and added these codes :
//******************************************************
void __fastcall TForm2::FormCreate(TObject *Sender)
{
ServerSocket1->Port = 23;
ServerSocket1->Active = true;
}
void __fastcall TForm2::ServerSocket1ClientRead(TObject
*Sender,TCustomWinSocket *Socket)
{
AnsiString T;
T = Socket->ReceiveText();
Memo1->Lines->Add(T);
}
//******************************************************
This was server side.
I also created another project.I dropped two TEdits, TClientSocket and a TButton.I wrote these codes :
//******************************************************
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
ClientSocket1->Active = false;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ClientSocket1->Port = 23;
ClientSocket1->Host = Edit2->Text;
ClientSocket1->Active = true;
if (ClientSocket1->Active)
ClientSocket1->Socket->SendText(Edit1->Text);
}
//******************************************************
It works but i should click Button twice.First click does not
triggers ServerSocket1ClientRead but second does.
What is the problem with it?
And i tried to write computer name instead ip number.It works
with ip number but doesn't work with Computer's name.
Mentor
Technical Details
Message-ID:
<4122266e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4121d280$1@newsgroups.borland.com> <4121e639$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5649840399278a78 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mentor" <mentor@nospam.com> Sender: "Mentor" <mentor@nospam.com> Reply-To: "Mentor" <mentor@nospam.com> Subject: Re: Send msg to another pc over network Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 81.215.244.208 References: <4121d280$1@newsgroups.borland.com> <4121e639$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <4122266e$1@newsgroups.borland.com> Date: 17 Aug 2004 08:38:22 -0700 X-Trace: newsgroups.borland.com 1092757102 207.105.83.66 (17 Aug 2004 08:38:22 -0700) Lines: 47 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail