🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4508

Re: stThreadBlocking Vs stNonBlocking confusion

#4508
From: Stefano Bonifazi
Date: Tue, 01 Feb 2005 17:25
94 lines
4146 bytes
To add more confusion :) I did a simple test, two very basic applications to 
test the threadblocking server ... of course they don't work (or better they 
work if I set nonblocking for the server too!)

The Server application:

A simple TServerSocket with Active=true, port=1024, 
ServerType=stThreadBlocking
A simple TMemo

void __fastcall TForm2::ServerSocket1ClientConnect(TObject *Sender,
      TCustomWinSocket *Socket)
{
 Memo1->Lines->Add("Client connected");
}
//---------------------------------------------------------------------------

void __fastcall TForm2::ServerSocket1ClientRead(TObject *Sender,
      TCustomWinSocket *Socket)
{
 Memo1->Lines->Add("Inside OnClientRead");
 Application->ProcessMessages();
 Memo1->Lines->Add("Client: "+Socket->ReceiveText());
 Application->ProcessMessages();
 Socket->SendText("Bye!");
}
//---------------------------------------------------------------------------

void __fastcall TForm2::ServerSocket1ClientWrite(TObject *Sender,
      TCustomWinSocket *Socket)
{
 Memo1->Lines->Add("OnClientWrite");
 Socket->SendText("Bye!");
}
//---------------------------------------------------------------------------
void __fastcall TForm2::ServerSocket1ClientError(TObject *Sender,
      TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
{
 Memo1->Lines->Add("Error");
}
//---------------------------------------------------------------------------

It seems dead, nothing is written to the Memo :(


The Client Application:
 A simple TClientSocket with Port=1024, Address=127.0.0.1, Active=false, 
ClientType=ctNonBlocking
 A simple TMemo, A TStatusBar, 2 TButtons

void __fastcall TForm1::Button2Click(TObject *Sender)
{
 ClientSocket1->Active=true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
 if(ClientSocket1->Socket->Connected)
  ClientSocket1->Socket->SendText(Edit1->Text);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ClientSocket1Connect(TObject *Sender,
      TCustomWinSocket *Socket)
{
 StatusBar1->SimpleText="Connected";
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ClientSocket1Read(TObject *Sender,
      TCustomWinSocket *Socket)
{
 Memo1->Lines->Add("Server: "+Socket->ReceiveText());
}
//---------------------------------------------------------------------------


void __fastcall TForm1::ClientSocket1Error(TObject *Sender,
      TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
{
 StatusBar1->SimpleText="Error";
}
//---------------------------------------------------------------------------

After I've clicked Button2, I can see that the OnConnect event handler has 
been executed, but if then I click the Button1 nothing happens! :(

Where do I mistake? It's so discouraging when after so much study, even so 
simple test does not run ;(

Thank You all for Your help!

Stefano b.
Technical Details
Message-ID: <41ffbb99@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!fu-berlin.de!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41fe906e@newsgroups.borland.com> <41fe99bf$1@newsgroups.borland.com> <41ff64b9@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,4f7607071b9a8537
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Stefano Bonifazi" <stefboombastic@email.it>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <41fe906e@newsgroups.borland.com> <41fe99bf$1@newsgroups.borland.com> <41ff64b9@newsgroups.borland.com>
Subject: Re: stThreadBlocking Vs stNonBlocking confusion
Date: Tue, 1 Feb 2005 18:25:46 +0100
Lines: 99
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; Response
NNTP-Posting-Host: 212.141.203.213
Message-ID: <41ffbb99@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1107278745 212.141.203.213 (1 Feb 2005 09:25:45 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!fu-berlin.de!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail