You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

8 years ago
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
8 years ago
​
​
​
8 years ago
​
​
​
8 years ago
​
8 years ago
  1. #ifndef __SOCKETTRANSPORT_H_INCL__
  2. #define __SOCKETTRANSPORT_H_INCL__
  3. #include "../../components/base/basicDualThread.h"
  4. #include "../../components/base/basicTransport.h"
  5. #include <sys/types.h>
  6. #include <sys/select.h>
  7. #include <unistd.h>
  8. #define MAXIMAL_SOCKET_PACKET_LENGTH 4194304 // 4Mb
  9. /**
  10. * TODO: Add class description
  11. *
  12. * @author Gagua
  13. */
  14. class transportSocket : public basicTransport, public basicDualThread {
  15. private:
  16. basicLogCollection *m_pLog;
  17. protected:
  18. U8 m_pInputBuffer[MAXIMAL_SOCKET_PACKET_LENGTH];
  19. U8 m_pOutputBuffer[MAXIMAL_SOCKET_PACKET_LENGTH];
  20. int m_nInputBufferSize;
  21. int m_nOutputBufferSize;
  22. int m_nSenderSetMax;
  23. int m_nReaderSetMax;
  24. fd_set m_sSenderSet;
  25. fd_set m_sReaderSet;
  26. int m_iControlPipeFD[2];
  27. bool m_bInitComplete;
  28. virtual void m_fThreadAProc(void);
  29. virtual void m_fThreadBProc(void);
  30. virtual int sendBlock(unsigned char *Data, int DataSize){ return 0; };
  31. virtual int recptBlock(unsigned char *Buffer, int *BufferLength){ return 0; };
  32. public:
  33. transportSocket();
  34. virtual ~transportSocket();
  35. virtual bool sendData(unsigned char *Data, int DataSize);
  36. virtual bool reconnect( void ){ return false; };
  37. virtual bool create( void );
  38. virtual bool _close( void );
  39. };
  40. #endif // __SOCKETTRANSPORT_H_INCL__