$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_ReceiverSocket_h_ 00002 #define _ots_ReceiverSocket_h_ 00003 00004 #include "otsdaq-core/NetworkUtilities/Socket.h" 00005 00006 #include <mutex> //for std::mutex 00007 #include <string> 00008 #include <vector> 00009 00010 namespace ots 00011 { 00012 class ReceiverSocket : public virtual Socket 00013 { 00014 // TransceiverSocket is a "Friend" class of ReceiverSocket so has access to private 00015 // members. 00016 friend class TransceiverSocket; 00017 00018 public: 00019 ReceiverSocket(std::string IPAddress, unsigned int port = 0); 00020 virtual ~ReceiverSocket(void); 00021 00022 int receive(std::string& buffer, 00023 unsigned int timeoutSeconds = 1, 00024 unsigned int timeoutUSeconds = 0, 00025 bool verbose = false); 00026 int receive(std::vector<uint32_t>& buffer, 00027 unsigned int timeoutSeconds = 1, 00028 unsigned int timeoutUSeconds = 0, 00029 bool verbose = false); 00030 int receive(std::string& buffer, 00031 unsigned long& fromIPAddress, 00032 unsigned short& fromPort, 00033 unsigned int timeoutSeconds = 1, 00034 unsigned int timeoutUSeconds = 0, 00035 bool verbose = false); 00036 int receive(std::vector<uint32_t>& buffer, 00037 unsigned long& fromIPAddress, 00038 unsigned short& fromPort, 00039 unsigned int timeoutSeconds = 1, 00040 unsigned int timeoutUSeconds = 0, 00041 bool verbose = false); 00042 00043 protected: 00044 ReceiverSocket(void); 00045 00046 private: 00047 fd_set fileDescriptor_; 00048 struct timeval timeout_; 00049 struct sockaddr_in fromAddress_; 00050 socklen_t addressLength_; 00051 int numberOfBytes_; 00052 00053 unsigned long dummyIPAddress_; 00054 unsigned short dummyPort_; 00055 unsigned int readCounter_; 00056 00057 std::mutex 00058 receiveMutex_; // to make receiver socket thread safe 00059 // i.e. multiple threads can share a socket and call receive() 00060 }; 00061 00062 } // namespace ots 00063 00064 #endif