Logo
~Sockets~
~Examples~
~Contact~


stprog.cpp File Reference

#include <stdio.h>
#include <ListenSocket.h>
#include "InSocket.h"
#include "ProxyHandler.h"
#include <signal.h>
#include <StdoutLog.h>

Include dependency graph for stprog.cpp:

Go to the source code of this file.


Defines

#define DEB(x)

Functions

void sigint (int s)
void sighup (int s)
void sigusr1 (int s)
void sigusr2 (int s)
void sigpipe (int s)
void siginit (void)
void run ()
int main (int argc, char *argv[])

Variables

static int m_quit = 0

Define Documentation

#define DEB (  ) 

Definition at line 29 of file stprog.cpp.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 97 of file stprog.cpp.

References run(), and siginit().

00098 {
00099         siginit();
00100         run();
00101 }

void run (  ) 

Definition at line 71 of file stprog.cpp.

References m_quit, and ProxyHandler::ViewSockets().

Referenced by main().

00072 {
00073         size_t sz = 0;
00074         ProxyHandler h;
00075         StdoutLog log;
00076         h.RegStdLog(&log);
00077         ListenSocket<InSocket> l(h);
00078 
00079         if (l.Bind( 8080 ))
00080         {
00081                 exit(-1);
00082         }
00083         h.Add(&l);
00084         while (!m_quit)
00085         {
00086                 h.Select(1, 0);
00087                 if (h.GetCount() != sz)
00088                 {
00089                         sz = h.GetCount();
00090                         h.ViewSockets();
00091                 }
00092         }
00093         printf("Ctrl-C...\n");
00094 }

void sighup ( int  s  ) 

Definition at line 42 of file stprog.cpp.

References DEB, and m_quit.

Referenced by siginit().

00043 {
00044 DEB(    printf("sighup\n");)
00045         m_quit++;
00046 }

void siginit ( void   ) 

Definition at line 60 of file stprog.cpp.

References sighup(), sigint(), sigpipe(), sigusr1(), and sigusr2().

Referenced by main().

00061 {
00062         signal(SIGINT, (__sighandler_t)sigint);
00063         signal(SIGHUP, (__sighandler_t)sighup);
00064         signal(SIGUSR1, (__sighandler_t)sigusr1);
00065         signal(SIGUSR2, (__sighandler_t)sigusr2);
00066         signal(SIGPIPE, (__sighandler_t)sigpipe);
00067 }

void sigint ( int  s  ) 

Definition at line 36 of file stprog.cpp.

References DEB, and m_quit.

Referenced by siginit().

00037 {
00038 DEB(    printf("sigint\n");)
00039         m_quit++;
00040 }

void sigpipe ( int  s  ) 

Definition at line 56 of file stprog.cpp.

Referenced by siginit().

00057 {
00058 }

void sigusr1 ( int  s  ) 

Definition at line 48 of file stprog.cpp.

Referenced by siginit().

00049 {
00050 }

void sigusr2 ( int  s  ) 

Definition at line 52 of file stprog.cpp.

Referenced by siginit().

00053 {
00054 }


Variable Documentation

int m_quit = 0 [static]

Definition at line 32 of file stprog.cpp.

Referenced by run(), sighup(), and sigint().

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