🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Non-blocking socket - how to detect when server has finished writing to client

#2969
From: Mark Jacobs
Date: Sat, 31 Dec 2005 22:01
26 lines
2067 bytes
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> wrote on Sat, 31 Dec 2005 18:20:58 +0100 :-
> 5) client receives answer

I have found a way round it. In my app, a POP3 mail lister for heavily-spammed accounts, the reply to all POP3 
commands is either very short, or multi-line and terminated with a line starting with a full stop. In the long 
requests like RETR and TOP x y, I stop waiting to read any more when I get this line in my buffer. It works a treat 
for a single-threaded VCL app, with the occasional hiccup. Here is my revised code :-

// Globals int wh (length of the buffer so far), char *bf (buffer)
// bool needot (wait until a dot is recvd.), bool dun ("got everything from server" flag)
void __fastcall TForm1::ClientSocket1Read(TObject *Sender,TCustomWinSocket *Socket)
{
  int ii=1;
  while (ii>0)
  {
    ii=Socket->ReceiveBuf(&bf[wh],2048);
    wh+=ii; bf[wh]='\0'; if (ii>0) Sleep(10);
  }
  dun=(!needot || AnsiString(bf).Pos("\r\n.")>0);
}

Now I need to add in the spam filtering, and decode attachments embedded in the output of RETR. Isn't there a 
free VCL add-on to decode attachments somewhere? Also, is 2048 a good read value to use?

Mark Jacobs
Technical Details
Message-ID: <43b70dbb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <43b66ea8@newsgroups.borland.com> <43b6bd83@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,e5c1e8b6c618095e
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
X-Newsreader: MJ News Reader
From: Mark Jacobs
ReplyTo: markhatesspam@spamcatcher.com
Subject: Re: Non-blocking socket - how to detect when server has finished writing to client
Newsgroups: borland.public.cppbuilder.internet.socket
References:   <43b66ea8@newsgroups.borland.com> <43b6bd83@newsgroups.borland.com>
NNTP-Posting-Host: 81.86.141.233
Message-ID: <43b70dbb$1@newsgroups.borland.com>
Date: 31 Dec 2005 15:01:15 -0700
X-Trace: newsgroups.borland.com 1136070075 81.86.141.233 (31 Dec 2005 15:01:15 -0700)
Lines: 26
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail