Logo
~Sockets~
~Examples~
~Contact~


ServerSocket Class Reference

#include <ServerSocket.h>

List of all members.


Public Member Functions

 ServerSocket (ISocketHandler &)
 ~ServerSocket ()
void OnLine (const std::string &)

Detailed Description

Definition at line 8 of file ServerSocket.h.


Constructor & Destructor Documentation

ServerSocket::ServerSocket ( ISocketHandler &   ) 

Definition at line 8 of file ServerSocket.cpp.

00009 :TcpSocket(h)
00010 {
00011         SetLineProtocol();
00012 }

ServerSocket::~ServerSocket (  ) 

Definition at line 15 of file ServerSocket.cpp.

00016 {
00017 }


Member Function Documentation

void ServerSocket::OnLine ( const std::string &   ) 

Definition at line 20 of file ServerSocket.cpp.

00021 {
00022         if (cmd == "QUIT")
00023         {
00024                 Send("BYE\n\n");
00025                 SetCloseAndDelete();
00026         }
00027         else
00028         if (cmd == "TIME")
00029         {
00030                 time_t t = time(NULL);
00031                 struct tm* tp = localtime(&t);
00032                 char datetime[40];
00033                 sprintf(datetime,"%d-%02d-%02d %02d:%02d:%02d",
00034                         tp -> tm_year + 1900,
00035                         tp -> tm_mon + 1,
00036                         tp -> tm_mday,
00037                         tp -> tm_hour,
00038                         tp -> tm_min,
00039                         tp -> tm_sec);
00040                 std::string reply = "TIME: ";
00041                 reply += datetime;
00042                 reply += "\n";
00043                 for (int i = 0; i < 10; i++)
00044                         Send(reply);
00045                 Send("\n");
00046         }
00047         else
00048         if (cmd == "HELP")
00049         {
00050                 Send("Commands supported: QUIT TIME HELP\n\n");
00051         }
00052         else
00053         {
00054                 Send("404 Not found\n\n");
00055         }
00056 }


The documentation for this class was generated from the following files:
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