00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SOCKETAGENT__
00009 #define __SOCKETAGENT__
00010
00011 #include <sys/socket.h>
00012 #include <netinet/in.h>
00013 #include <netdb.h>
00014
00015 #include <string>
00016
00017 namespace edg {
00018 namespace workload {
00019 namespace common {
00020 namespace socket_pp {
00021
00029 class SocketAgent
00030 {
00031 public:
00032
00038 virtual bool Send(const std::string&);
00044 virtual bool Send(int);
00050 virtual bool Send(long);
00051
00057 virtual bool Receive(int&);
00063 virtual bool Receive(long&);
00069 virtual bool Receive(std::string&);
00070
00075 std::string HostName();
00081 bool SetTimeout(size_t);
00087 bool SetRcvTimeout(size_t);
00093 bool SetSndTimeout(size_t);
00094 protected:
00095
00099 SocketAgent();
00103 virtual ~SocketAgent();
00104
00105 private:
00112 bool sendbuffer(char *, unsigned int);
00119 bool readbuffer(char *, unsigned int);
00120
00122 friend class SocketServer;
00124 friend class SocketClient;
00125
00126 struct sockaddr_in peeraddr_in;
00128 protected:
00130 int sck;
00131 };
00132
00133 }
00134 }
00135 }
00136 }
00137
00138
00139 #endif
00140
00141
00142
00143
00144
00145
00146
00147
00148