Article View: borland.public.cppbuilder.internet.socket
Article #3637Is PowerSocket blocking by default?
From: Volodymyr Novikov
Date: Sun, 07 Aug 2005 23:04
Date: Sun, 07 Aug 2005 23:04
73 lines
2926 bytes
2926 bytes
Hi,
I am writing a small application using TPowesock.
It appeared that event OnRead called over and over again even though all
incoming data is read. In the following code ReadLineEvent(TObject *Sender)
procedure always executed without incoming data.
Any suggestions?
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (Psock1->Connected)
{Button1->Caption="Connect";
Psock1->Disconnect();
Psock1->Tag=0;}
else Psock1->Connect();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Psock1Connect(TObject *Sender)
{
Button1->Caption="Disconnect";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Psock1->OnRead=ReadEvent;
}
//---------------------------------------------------------------------------
// This is the procedure that will be assigned to the OnRead event
void __fastcall TForm1::ReadEvent(TObject *Sender)
{
ch=Psock1->Read(1);
lastline=lastline+ch;
Bar1->Panels->Items[0]->Text=Bar1->Panels->Items[0]->Text+ch;
if (lastline=="login:")
{Psock1->Writeln(login);
Bar1->Panels->Items[1]->Text=login;
lastline="";
Bar1->Panels->Items[0]->Text="";}
if (lastline=="password:")
{Psock1->Writeln(password);
Bar1->Panels->Items[1]->Text=password;
lastline="";
Bar1->Panels->Items[0]->Text="";}
if (lastline==welcome)
{lastline="";
ch=Psock1->Read(2);
Psock1->TimeOut=50;
Psock1->OnRead=ReadLineEvent;}
}
//---------------------------------------------------------------------------
// This is the procedure that will be assigned to the OnRead event after
login was succsessful
void __fastcall TForm1::ReadLineEvent(TObject *Sender)
{
try
{
ch=Psock1->Read(1);
}
catch(...)
{
lastline=ch;
Bar1->Panels->Items[0]->Text=ch;
}
}
Technical Details
Message-ID:
<42f6938c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,d0b3c328cb5fdfcf,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Volodymyr Novikov" <v.novikov@sympatico.ca> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Is PowerSocket blocking by default? Date: Sun, 7 Aug 2005 19:04:44 -0400 Lines: 75 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 64.229.8.129 Message-ID: <42f6938c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1123455884 64.229.8.129 (7 Aug 2005 16:04:44 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail