00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _CSOCKET
00027 #define _CSOCKET
00028
00029 #include <cstdio>
00030 #include <unistd.h>
00031 #include <stdlib.h>
00032 #include <cerrno>
00033 #include <cstring>
00034 #include <functional>
00035 #include <cassert>
00036 #include <cstdio>
00037 #include <unistd.h>
00038 #include <stdlib.h>
00039 #include <cerrno>
00040 #include <cstring>
00041 #include <sys/types.h>
00042 #include <sys/socket.h>
00043 #include <sys/un.h>
00044
00045 #include <sys/types.h>
00046 #include <sys/stat.h>
00047 #include <iostream>
00048 #include <string>
00049 #include <cassert>
00050 using namespace std;
00056 class CSocket{
00057 public:
00059 class CServeFunction:public unary_function<bool,int>{
00060 public:
00061 virtual bool operator()(int inStream)=0;
00062 };
00063 protected:
00065 bool mIsInitialized;
00067 int mSocketDescriptor;
00069 CServeFunction* mServeFunction;
00070 public:
00072 CSocket();
00074 ~CSocket();
00076 int getSocketDescriptor()const;
00078 void setServeFunction(CServeFunction* inServeFunction);
00080 virtual bool acceptAndServe()=0;
00082 virtual void serveStream(int);
00084 virtual operator bool()const;
00085 };
00086 #endif