Logo
~Sockets~
~Examples~
~Contact~


chat.cpp File Reference

#include <stdio.h>
#include <signal.h>
#include <ListenSocket.h>
#include "ChatHandler.h"
#include "ChatSocket.h"

Include dependency graph for chat.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 26 of file chat.cpp.

Referenced by sighup(), and sigint().


Function Documentation

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

Definition at line 68 of file chat.cpp.

References m_quit, and siginit().

00069 {
00070         ChatHandler h;
00071         ListenSocket<ChatSocket> l(h);
00072 #ifdef _WIN32
00073         siginit();
00074 #endif
00075 
00076         if (l.Bind(4440))
00077         {
00078                 exit(-1);
00079         }
00080         h.Add(&l);
00081         while (!m_quit)
00082         {
00083                 h.Select(1,0);
00084         }
00085 }

void sighup ( int  s  ) 

Definition at line 39 of file chat.cpp.

References DEB, and m_quit.

Referenced by siginit().

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

void siginit ( void   ) 

Definition at line 57 of file chat.cpp.

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

Referenced by main().

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

void sigint ( int  s  ) 

Definition at line 33 of file chat.cpp.

References DEB, and m_quit.

Referenced by siginit().

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

void sigpipe ( int  s  ) 

Definition at line 53 of file chat.cpp.

Referenced by siginit().

00054 {
00055 }

void sigusr1 ( int  s  ) 

Definition at line 45 of file chat.cpp.

Referenced by siginit().

00046 {
00047 }

void sigusr2 ( int  s  ) 

Definition at line 49 of file chat.cpp.

Referenced by siginit().

00050 {
00051 }


Variable Documentation

int m_quit = 0 [static]

Definition at line 29 of file chat.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