Back to index

nordugrid-arc-nox  1.1.0~rc6
PayloadTCPSocket.h
Go to the documentation of this file.
00001 #ifndef __ARC_PAYLOADTCPSOCKET_H__
00002 #define __ARC_PAYLOADTCPSOCKET_H__
00003 
00004 #include <vector>
00005 
00006 #include <arc/message/PayloadStream.h>
00007 #include <arc/Logger.h>
00008 
00009 namespace Arc {
00010 
00012 class PayloadTCPSocket: public PayloadStreamInterface {
00013  private:
00014   int connect_socket(const char* hostname,int port);
00015   int handle_;
00016   bool acquired_;
00017   int timeout_;
00018   Logger& logger;
00019  public:
00021   PayloadTCPSocket(const char* hostname,int port, int timeout, Logger& logger);
00023   PayloadTCPSocket(const std::string endpoint,int timeout, Logger& logger);
00026   PayloadTCPSocket(int s, int timeout, Logger& logger):
00027     handle_(s),acquired_(false),timeout_(timeout),logger(logger) { };
00030   PayloadTCPSocket(PayloadTCPSocket& s):
00031     handle_(s.handle_),acquired_(false),timeout_(s.timeout_),logger(s.logger) { };
00034   PayloadTCPSocket(PayloadTCPSocket& s,Logger& logger):
00035     handle_(s.handle_),acquired_(false),timeout_(s.timeout_),logger(logger) { };
00036   virtual ~PayloadTCPSocket(void);
00037   virtual bool Get(char* buf,int& size);
00038   virtual bool Get(std::string& buf);
00039   virtual std::string Get(void) { std::string buf; Get(buf); return buf; };
00040   virtual bool Put(const char* buf,Size_t size);
00041   virtual bool Put(const std::string& buf) { return Put(buf.c_str(),buf.length()); };
00042   virtual bool Put(const char* buf) { return Put(buf,buf?strlen(buf):0); };
00043   virtual operator bool(void) { return (handle_ != -1); };
00044   virtual bool operator!(void) { return (handle_ == -1); };
00045   virtual int Timeout(void) const { return timeout_; };
00046   virtual void Timeout(int to) { timeout_=to; };
00047   virtual Size_t Pos(void) const { return 0; };
00048   virtual Size_t Size(void) const { return 0; };
00049   virtual Size_t Limit(void) const { return 0; };
00050   int GetHandle() { return handle_; };
00051   void NoDelay(bool val);
00052 };
00053 
00054 } // namespace Arc 
00055 
00056 #endif /* __ARC_PAYLOADTCPSOCKET_H__ */
00057