$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_NetworkDevice_h_ 00002 #define _ots_NetworkDevice_h_ 00003 00004 #include <netinet/in.h> 00005 #include <map> 00006 #include <string> 00007 00008 struct ifaddrs; 00009 00010 namespace ots 00011 { 00012 class NetworkDevice 00013 { 00014 public: 00015 NetworkDevice(std::string IPAddress, unsigned int port); 00016 ~NetworkDevice(); 00017 00018 int initSocket(std::string socketPort = ""); 00019 int initSocket(unsigned int socketPort); 00020 // int closeSocket(std::string socketPort=""); 00021 int ping(int socketDescriptor); 00022 int send(int socketDescriptor, const std::string& msg); 00023 int receive(int socketDescriptor, std::string& msg); 00024 int listen(int socketDescriptor, std::string& msg); 00025 std::string getFullIPAddress(std::string partialIpAddress); 00026 std::string getInterfaceName(std::string ipAddress); 00027 std::string getMacAddress(std::string interfaceName); 00028 00029 protected: 00030 enum 00031 { 00032 maxSocketSize = 65536 00033 }; 00034 00035 struct sockaddr_in deviceAddress_; 00036 // socket,socket port 00037 std::map<int, int> openSockets_; 00038 00039 private: 00040 enum 00041 { 00042 FirstSocketPort = 10000, 00043 LastSocketPort = 15000 00044 }; 00045 00046 int getInterface(std::string partialIpAddress); 00047 00048 struct ifaddrs* communicationInterface_; // Interface communicating with device aka 00049 // computer interface 00050 }; 00051 00052 } // namespace ots 00053 00054 #endif