Snippets: SocksArmor - BlackboardSimpleRemoteBackup
// SOCKSArmor Snippets - SocksArmor. // Author: Felipe Kellermann <felipek@socksarmor.org> // Revision: $Revision: 5395 $ // Date: $Date: 2008-01-03 18:05:06 -0200 (Thu, 03 Jan 2008) $ // // This snippet offers a *very* simple "remote backup" example utility // that takes a blackboard (export) from one server and saves (imports) // it into another server: this is a very simple synchronization tool. using System; using System.Threading; using SocksArmor; class SocksArmorSnippet { static void Main(string[] args) { // Remote SOCKSArmor server (master). RemoteServer master = new RemoteServer(); master.Connect("10.0.0.35", 10842, "username", "password"); // Remote SOCKSArmor server (slave). RemoteServer slave = new RemoteServer(); slave.Connect("10.0.0.36", 10842, "username", "password"); while (true) { // Takes the master XML blackboard configuration. string blackboard = master.Blackboard.Export(); // Slave's blackboard gets reseted and receives another // blackboard information. Note that a *reset* is commonly // followed by an *import* call. slave.Blackboard.Reset(); slave.Blackboard.Import(blackboard); // Outputs some *dummy* information to inform about the // operation. Note that both Export, Reset and Import // returns nothing though they can all throw exceptions. Console.WriteLine("Sucessfuly synched between {0} and {1}: {2} bytes", master.RemoteHost, slave.RemoteHost, blackboard.Length); // Sleep waiting for another sync round. System.Threading.Thread.Sleep(30 * 1000); } } }
