00001
00002
00003
00004
00005
00006
00007
00008
00018 #ifndef _SocketServer_h__
00019 #define _SocketServer_h_
00020
00021 #include <sys/socket.h>
00022 #include <netinet/in.h>
00023 #include <pthread.h>
00024
00025 #include <list>
00026 #include <string>
00027
00028 namespace edg {
00029 namespace workload {
00030 namespace common {
00031 namespace socket_pp {
00032
00034 class SocketAgent;
00035
00044 class SocketServer
00045 {
00046 public:
00047
00053 SocketServer(int, int=5);
00058 virtual ~SocketServer();
00059
00064 bool Open();
00065
00070 bool IsConnectionPending();
00071
00075 virtual void Close();
00082 virtual SocketAgent* Listen(SocketAgent* = 0);
00083
00089 void KillAgent(SocketAgent*);
00090
00091 private:
00092
00093 struct sockaddr_in myaddr_in;
00094 pthread_mutex_t* agent_mutex;
00095 std::string hostname;
00096 int port;
00097 int backlog;
00098 std::list<SocketAgent*> agents;
00100 protected:
00102 int sck;
00103 };
00104
00105 }
00106 }
00107 }
00108 }
00109
00110
00111 #endif
00112
00113
00114
00115
00116
00117
00118
00119
00120