00001 #ifndef _ots_ReceiverSocket_h_
00002 #define _ots_ReceiverSocket_h_
00003
00004 #include "otsdaq-core/NetworkUtilities/Socket.h"
00005
00006 #include <string>
00007 #include <vector>
00008 #include <mutex>
00009
00010 namespace ots
00011 {
00012
00013 class ReceiverSocket : public virtual Socket
00014 {
00015 public:
00016 ReceiverSocket(std::string IPAddress, unsigned int port=0);
00017 virtual ~ReceiverSocket(void);
00018
00019 int receive(std::string& buffer, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=true);
00020 int receive(std::vector<uint32_t>& buffer, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=true);
00021 int receive(std::string& buffer, unsigned long& fromIPAddress, unsigned short& fromPort, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=true);
00022 int receive(std::vector<uint32_t>& buffer, unsigned long& fromIPAddress, unsigned short& fromPort, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=true);
00023
00024 protected:
00025 ReceiverSocket(void);
00026
00027 private:
00028 fd_set fileDescriptor_;
00029 struct timeval timeout_;
00030 struct sockaddr_in fromAddress_;
00031 socklen_t addressLength_;
00032 int numberOfBytes_;
00033
00034 unsigned long dummyIPAddress_;
00035 unsigned short dummyPort_;
00036 unsigned int readCounter_;
00037
00038 std::mutex receiveMutex_;
00039
00040
00041 };
00042
00043 }
00044
00045 #endif