Logo
~Sockets~
~Examples~
~Contact~


small.cpp File Reference

#include <stdio.h>
#include <signal.h>
#include <ListenSocket.h>
#include <StdoutLog.h>
#include "SmallHandler.h"
#include "SmallSocket.h"

Include dependency graph for small.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)
int main (int argc, char *argv[])

Variables

static int m_quit = 0

Define Documentation

#define DEB (  ) 

Definition at line 27 of file small.cpp.

Referenced by sighup(), and sigint().


Function Documentation

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

Definition at line 69 of file small.cpp.

References SmallHandler::Load(), m_quit, SmallHandler::SecTick(), and siginit().

00070 {
00071         time_t t = time(NULL);
00072         time_t osec = t;
00073         SmallHandler h;
00074         ListenSocket<SmallSocket> l(h);
00075         StdoutLog log;
00076 
00077         h.RegStdLog(&log);
00078         srandom(time(NULL));
00079         siginit();
00080 
00081         if (l.Bind(4441))
00082         {
00083                 exit(-1);
00084         }
00085         h.Add(&l);
00086         h.Load();
00087         while (!m_quit)
00088         {
00089                 h.Select(1,0);
00090                 t = time(NULL);
00091                 if (t != osec)
00092                 {
00093                         h.SecTick(t);
00094                         osec = t;
00095                 }
00096         }
00097 }

void sighup ( int  s  ) 

Definition at line 40 of file small.cpp.

References DEB, and m_quit.

Referenced by siginit().

00041 {
00042 DEB(    printf("sighup\n");)
00043         m_quit++;
00044 }

void siginit ( void   ) 

Definition at line 58 of file small.cpp.

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

Referenced by main().

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

void sigint ( int  s  ) 

Definition at line 34 of file small.cpp.

References DEB, and m_quit.

Referenced by siginit().

00035 {
00036 DEB(    printf("sigint\n");)
00037         m_quit++;
00038 }

void sigpipe ( int  s  ) 

Definition at line 54 of file small.cpp.

Referenced by siginit().

00055 {
00056 }

void sigusr1 ( int  s  ) 

Definition at line 46 of file small.cpp.

Referenced by siginit().

00047 {
00048 }

void sigusr2 ( int  s  ) 

Definition at line 50 of file small.cpp.

Referenced by siginit().

00051 {
00052 }


Variable Documentation

int m_quit = 0 [static]

Definition at line 30 of file small.cpp.

Referenced by main(), 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