🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Servers & Backup

#4253
From: Vladimir Stefanovic
Date: Wed, 09 Mar 2005 20:03
63 lines
2294 bytes
Imaginary scenario:

* I have a server (service app+serversocket)

* The server is supposed to receive files from
many clients,  and store it in some folder say:
C:\DATA

* I want to periodically make a backup (pure copy)
of the C:\DATA folder to C:\BACKUP folder.

* It's not of major importance that backup procedure
starts exactly at specified time (I can wait for current
connections to finish the procedure first)

* I want to wait for connections to be finished first because
I think I can receive some error like 'file is occupied'
otherwise.

* How can I wait for clients to finish the connections
first, and still be in position to inform them via same port
that backup procedure is in progress.

How would you do that?

This is some pseudo code of how I see that:

bool TimeForBackup = false;

SERVICE EXECUTE()
{
   if ( IsTimeForBackup() )
   {
      TimeForBackup = true;
      wait_for_global_number_of_connections_to_be_null()
      BACKUP()
      TimeForBackup = false;
   }
   // Continue loop ...
}


SERVER SOCKET GET THREAD()
{
   if ( TimeForBackup )
   {
      SEND_MESSAGE_BACK( Backup is in progress! )
      return;
   }

   ++global_number_of_connections;
   // Store file to C:\DATA

   // Close the connection
   --global_number_of_connections;
}




-- 
Best regards,
Vladimir Stefanovic 
Technical Details
Message-ID: <422f5694@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newspeer2.se.telia.net!se.telia.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,1c128025d98be9a8,start
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
Subject: Servers & Backup
Date: Wed, 9 Mar 2005 21:03:32 +0100
Lines: 65
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
NNTP-Posting-Host: 82.117.212.65
Message-ID: <422f5694@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1110398612 82.117.212.65 (9 Mar 2005 12:03:32 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newspeer2.se.telia.net!se.telia.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail