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
00016 friend class TransceiverSocket;
00017 public:
00018 ReceiverSocket(std::string IPAddress, unsigned int port=0);
00019 virtual ~ReceiverSocket(void);
00020
00021 int receive(std::string& buffer, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=false);
00022 int receive(std::vector<uint32_t>& buffer, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=false);
00023 int receive(std::string& buffer, unsigned long& fromIPAddress, unsigned short& fromPort, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=false);
00024 int receive(std::vector<uint32_t>& buffer, unsigned long& fromIPAddress, unsigned short& fromPort, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=false);
00025
00026 protected:
00027 ReceiverSocket(void);
00028
00029 private:
00030 fd_set fileDescriptor_;
00031 struct timeval timeout_;
00032 struct sockaddr_in fromAddress_;
00033 socklen_t addressLength_;
00034 int numberOfBytes_;
00035
00036 unsigned long dummyIPAddress_;
00037 unsigned short dummyPort_;
00038 unsigned int readCounter_;
00039
00040 std::mutex receiveMutex_;
00041
00042
00043 };
00044
00045 }
00046
00047 #endif