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);
00098 int SocketDescriptor() { return sck; }
00099
00100
00101 protected:
00102
00106 SocketAgent();
00110 virtual ~SocketAgent();
00111
00112 private:
00119 bool sendbuffer(char *, unsigned int);
00126 bool readbuffer(char *, unsigned int);
00127
00129 friend class SocketServer;
00131 friend class SocketClient;
00132
00133 struct sockaddr_in peeraddr_in;
00135 protected:
00137 int sck;
00138 };
00139
00140 }
00141 }
00142 }
00143 }
00144
00145
00146 #endif
00147
00148
00149
00150
00151
00152
00153
00154
00155