CARMA C++
NetHandler.h
Go to the documentation of this file.
1 #ifndef SZA_UTIL_NETHANDLER_H
2 #define SZA_UTIL_NETHANDLER_H
3 
11 #include "carma/szautil/NetStr.h"
12 
13 namespace sza {
14  namespace util {
15 
16  class NetHandler {
17  public:
18 
22  NetHandler();
23 
27  NetHandler(int fd);
28 
32  virtual ~NetHandler();
33 
37  void attachReadStream(int fd);
38 
42  void attachSendStream(int fd);
43 
47  void attach(int fd);
48 
52  virtual int getReadFd();
53 
57  virtual int getSendFd();
58 
63  virtual int getFd();
64 
69  void setReadBuffer(void* buffer, unsigned int size);
70 
71 
76  void setSendBuffer(void* buffer, unsigned int size);
77 
82  sza::util::NetSendStr::NetSendId send();
83 
88  sza::util::NetSendStr::NetSendId send(int fd);
89 
94  sza::util::NetReadStr::NetReadId read();
95 
100  sza::util::NetReadStr::NetReadId read(int fd);
101 
105  inline NetReadStr* getReadStr() {
106  return nrs_;
107  }
108 
112  inline NetSendStr* getSendStr() {
113  return nss_;
114  }
115 
119  virtual void installReadHandler(NET_READ_HANDLER(*handler), void* arg);
120  virtual void installReadErrorHandler(NET_ERROR_HANDLER(*handler),
121  void* arg);
122  virtual void installSendHandler(NET_SEND_HANDLER(*handler), void* arg);
123  virtual void installSendErrorHandler(NET_ERROR_HANDLER(*handler),
124  void* arg);
125  virtual void installErrorHandler(NET_ERROR_HANDLER(*handler),
126  void* arg);
127 
128  protected:
129 
130  int fd_;
131  NetReadStr* nrs_;
132  NetSendStr* nss_;
133 
134  private:
135 
136  void initialize();
137 
138  }; // End class NetHandler
139 
140  } // End namespace util
141 } // End namespace sza
142 
143 
144 
145 #endif // End #ifndef SZA_UTIL_NETHANDLER_H
Started: Tue Mar 2 03:37:15 UTC 2004.