 ~Sockets~
|
C++ Socket library tutorial
|
|
Error logging
To turn on error logging, the class StdLog is used.
The library contains the StdoutLog class as an example on how to use StdLog.
It only has one method (error) that is called by the framework whenever
something bad happens.
To use a log class, it needs to be instantiated and registered with the
SocketHandler. One example on how to do this is shown below. It's the
displayserver that has been complemented with error logging.
The StdLog and StdoutLog classes were added in version 1.4.
server_errlog.cpp
#include <SocketHandler.h>
#include <ListenSocket.h>
#include <StdoutLog.h>
#include "DisplaySocket.h"
static bool quit = false;
int main()
{
SocketHandler h;
ListenSocket<DisplaySocket> l(h);
StdoutLog log;
h.RegStdLog(&log);
if (l.Bind(9001))
{
exit(-1);
}
h.Add(&l);
h.Select(1,0);
while (!quit)
{
h.Select(1,0);
}
}
|
|
|