Logo
~Sockets~
~Examples~
~Contact~


master.cpp

Go to the documentation of this file.
00001 #include <ListenSocket.h>
00002 #include <signal.h>
00003 #include <StdoutLog.h>
00004 
00005 #include "MHandler.h"
00006 #include "MasterSocket.h"
00007 #include "ExtSocket.h"
00008 //#include "ProxyInSocket.h"
00009 #include "AdminSocket.h"
00010 
00011 
00012 int main()
00013 {
00014         StdoutLog log;
00015         MHandler h(&log);
00016         h.LoadConfig();
00017         h.SaveConfig();
00018         //
00019         signal(SIGPIPE, SIG_IGN);
00020         //
00021         ListenSocket<MasterSocket> l(h);
00022         if (l.Bind(h.GetListenPort()))
00023         {
00024                 printf("Bind failed\n");
00025                 exit(-1);
00026         }
00027         printf("Listening for incoming slave connection on port %u\n", h.GetListenPort());
00028         h.Add(&l);
00029         //
00030 /*
00031         ListenSocket<ProxyInSocket> l6(h);
00032         if (l6.Bind(h.GetProxyPort()))
00033         {
00034                 printf("Bind failed\n");
00035                 exit(-1);
00036         }
00037         printf("HTTP proxy listening on port %u\n", h.GetProxyPort());
00038         h.Add(&l6);
00039 */
00040         ListenSocket<AdminSocket> l7(h);
00041         if (l7.Bind(h.GetAdminPort()))
00042         {
00043                 printf("Bind on port %d failed\n", h.GetAdminPort());
00044                 exit(-1);
00045         }
00046         printf("Admin listening on port %u\n", h.GetAdminPort());
00047         h.Add(&l7);
00048         //
00049         h.StartServices();
00050         //
00051         while (true)
00052         {
00053                 h.Select(1,0);
00054         }
00055 }
00056 
00057 
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4