tcpSerEpoll.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /***** (C) Copyright, Shenzhen SUNWIN Intelligent Co.,Ltd. ******source file****
  2. * File name : main.cpp
  3. * Author : ShengYin Li
  4. * Brief :
  5. ********************************************************************************
  6. * modify
  7. * Version Date Author Described
  8. * V1.00 2021/04/1 ShengYin Li Created
  9. *******************************************************************************/
  10. #pragma once
  11. #include <sys/socket.h>
  12. #include <netinet/in.h>
  13. #include <arpa/inet.h>
  14. #include <fcntl.h>
  15. #include <stdio.h>
  16. #include <errno.h>
  17. #include <iostream>
  18. #include <stdlib.h>
  19. #include <malloc.h>
  20. #include <sys/types.h>
  21. #include <sys/un.h>
  22. #include <sys/epoll.h>
  23. #include <sys/uio.h>
  24. #include <string.h>
  25. #include <unistd.h>
  26. #include "sdc_common.h"
  27. #include "tcpEpoll.h"
  28. #include "sdc.h"
  29. #include "inifile.h"
  30. #include "md5.h"
  31. #include "device/deviceGas.h"
  32. #include "dataType/NettyClientCommandEnum.h"
  33. #include "dataType/NettyClientResultMsg.h"
  34. #include "dataType/NettyServerCommandEnum.h"
  35. #include "dataType/NettyServerResultMsg.h"
  36. #include "dataType/RecDeviceCommand.h"
  37. #include "dataType/RecDeviceInfo.h"
  38. #include "dataType/SendLogin.h"
  39. #include "dataType/SendHeartBeat.h"
  40. #include "dataType/SendDevice.h"
  41. #include "dataType/SendBird.h"
  42. class tcpSerEpoll: public tcpEpoll
  43. {
  44. private:
  45. int _tproxy_fd;
  46. int _socket_fd;
  47. struct sockaddr_in servaddr;
  48. const char* _path;
  49. const std::string config_src = "../config/config.ini";
  50. bool handleAccept();
  51. int start();
  52. bool init(const char* path, const char * filter);
  53. void handleEvents(epoll_event * events, int num, char * buf, int &buf_len);
  54. bool doEpoll();
  55. public:
  56. tcpSerEpoll();
  57. ~tcpSerEpoll();
  58. std::string m_serverIp = "192.168.31.95";
  59. int m_serverPort = 8080;
  60. std::string m_usr;
  61. std::string m_pwd;
  62. string m_serverName = "web";
  63. std::string m_vpnIp;
  64. std::string m_cameraIp;
  65. int getSocket_fd();
  66. int getTproxy_fd();
  67. static void* insert_pth(void *);
  68. bool connect(string idName, const char* ip, int port);
  69. bool connect();
  70. void allClose();
  71. int lanch();
  72. };
  73. /******** (C) Copyright, Shenzhen SUNWIN Intelligent Co.,Ltd. ******** End *****/