🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Simple e-mail server

#3394
From: Vladimir Stefanovic
Date: Tue, 27 Sep 2005 18:54
74 lines
2974 bytes
> That is dependant on the speed of the DB,

Inserting new record in MS ACCESS (*.mdb) with
TADOTable is prety fast from my experience.

> and the speed of the protection that you use for
> guarding the DB from threading issues.

The only protection I know for are CriticalSections
(which I learned from you).

// PSEUDO !!!
bool AddNewRecord()
{
   RAII_LOCK();

   DB->Open();
   DB->TABLE->InsertNewRow(DATA);
   DB->Close();
}


> Why are you writing to the DB in the OnGetThread event
> handler, though? That is a very odd place to do it.  Or do
> you mean that your DB code is in the thread that is started
> by OnGetThread and is not inside of OnGetThread itself?

This is what I ment / I shortened the code as far as I could /

void __fastcall TAccountsService::ServerSocketGetThread(TObject *Sender,
      TServerClientWinSocket *ClientSocket,
      TServerClientThread *&SocketThread)
{
   SocketThread = new TAccountsServerThread( false, ClientSocket );
}
//---------------------------------------------------------------------------

void __fastcall TAccountsServerThread::ClientExecute()
{
   TMemoryStream *InboxMemoryStream = new TMemoryStream;
   TWinSocketStream *Stream = new TWinSocketStream ( ClientSocket, 5000 );

   try
   {
      while ( ( !Terminated ) && ( ClientSocket->Connected ) )
      {
         if ( Stream->WaitForData ( 5000 ) )
         {
            if( !ReadData ( Stream, InboxMemoryStream, 1000 ) )
            {
               ClientSocket->Close();
               break;
            }

            // SAVING TO DB CODE (PSEUDO, SHOWN ABOVE)
           bool Result = AddNewRecord();

            SendingNotificationToClientIfTheTaskWasSuccessfulOrNot( Stream, 
InboxMemoryStream, Result );
         }
      }
      // From here connection is closed ...
   }
   __finally
   {
      delete Stream;
      delete InboxMemoryStream;
   }
}


-- 
Best regards,
Vladimir Stefanovic 
Technical Details
Message-ID: <43399502@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4337dfe1$1@newsgroups.borland.com> <4338297e@newsgroups.borland.com> <43396990@newsgroups.borland.com> <43397d3c$3@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,97b4b095375844bd
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <4337dfe1$1@newsgroups.borland.com> <4338297e@newsgroups.borland.com> <43396990@newsgroups.borland.com> <43397d3c$3@newsgroups.borland.com>
Subject: Re: Simple e-mail server
Date: Tue, 27 Sep 2005 20:54:41 +0200
Lines: 76
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: 82.117.212.65
Message-ID: <43399502@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1127847170 82.117.212.65 (27 Sep 2005 11:52:50 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail