00001
00002 #ifndef NDS2SOCKET_HH
00003 #define NDS2SOCKET_HH
00004
00005
00006
00007 #include "DAQC_api.hh"
00008
00080
00090 class NDS2Socket :public DAQC_api {
00091 public:
00092 using DAQC_api::GetData;
00093
00096 NDS2Socket(void);
00097
00102 explicit NDS2Socket(const std::string& ipaddr, int ipport = NDS2_PORT,
00103 long RcvBufferLen = 16384);
00104
00107 ~NDS2Socket(void);
00108
00116 int open (const std::string& ipaddr, int ipport = NDS2_PORT,
00117 long bufsize = 16384);
00118
00121 void close();
00122
00125 void flush();
00126
00137 int Available (chantype typ, long gps, std::vector<DAQDChannel>& list,
00138 wait_time timeout=-1);
00139
00147 int GetData(wait_time timeout = -1);
00148
00153 int RequestOnlineData (double stride=1.0, wait_time timeout=-1);
00154
00160 int RequestData (unsigned long start, unsigned long duration,
00161 wait_time timeout=-1);
00162
00168 int StopWriter(void);
00169
00174 int Times (chantype typ, unsigned long& start, unsigned long& duration,
00175 wait_time timeout = -1);
00176
00184 int WaitforData (bool poll);
00185
00186 private:
00191 int authenticate(const char* server);
00192
00196 int gets(char* buf, int buflen);
00197
00201 int puts(const char* buf, int buflen);
00202
00203
00209 int RecvData(wait_time timeout = -1);
00210
00216 int RecvRec(char *buf, long len, bool readall=false,
00217 wait_time maxwait=-1);
00218
00222 int RecvReconfig(unsigned long len, wait_time maxwait=-1);
00223
00227 int SendRec(const char *buffer, long length, wait_time maxwait=-1);
00228
00239 int SendRequest(const std::string& text, char *reply=0, long length=0,
00240 long *Size=0, wait_time maxwait=-1);
00241
00242 private:
00245 int mSocket;
00246
00249 int mOffline;
00250
00253 void* mAuthContxt;
00254
00255 private:
00256 static bool sasl_init;
00257 };
00258
00261 #endif // NDS2SOCKET_HH
00262