Old fashion design for PC-104
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.

69 lines
2.0 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 05/11/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgSocket.h
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of LgSocket.h
  13. //----------------------------------------------------------------------------
  14. #ifndef __LG__SOCKET__H__INCLUDED__
  15. #define __LG__SOCKET__H__INCLUDED__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #include "..\..\LgLib\Thread.h"
  20. #include "..\Templ.h"
  21. class CLgSocket :
  22. public CLgThread
  23. {
  24. public:
  25. CLgSocket();
  26. virtual ~CLgSocket();
  27. public:
  28. BOOL Create( UINT nSocketPort = 0, int nSocketType = SOCK_STREAM, long lEvent = FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE, LPCTSTR lpszSocketAddress = NULL );
  29. public:
  30. SOCKET GetSocketHandle();
  31. public:
  32. virtual void Close();
  33. virtual BOOL Accept( CLgSocket& rConnectedSocket, SOCKADDR* lpSockAddr = NULL, int* lpSockAddrLen = NULL );
  34. virtual int Send( const void* lpBuf, int nBufLen, int nFlags = 0 );
  35. virtual int Receive( void* lpBuf, int nBufLen, int nFlags = 0 );
  36. BOOL GetSockName( SOCKADDR* lpSockAddr, int* lpSockAddrLen );
  37. BOOL AsyncSelect( long lEvent = FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE );
  38. BOOL Listen( int nConnectionBacklog = 5 );
  39. BOOL Connect( LPCTSTR lpszHostAddress, UINT nHostPort );
  40. BOOL Connect( const SOCKADDR* lpSockAddr, int nSockAddrLen );
  41. protected:
  42. virtual void OnAccept( int nErrorCode );
  43. virtual void OnConnect( int nErrorCode );
  44. virtual void OnClose( int nErrorCode );
  45. virtual void OnOutOfBandData( int nErrorCode );
  46. virtual void OnReceive( int nErrorCode );
  47. virtual void OnSend( int nErrorCode );
  48. protected:
  49. void DoHandleEvents();
  50. HANDLE GetSocketEventHandle();
  51. protected:
  52. virtual DWORD ThreadProc();
  53. private:
  54. SOCKET m_hSocket;
  55. long m_lEventMask;
  56. HANDLE m_hSocketEvent;
  57. };
  58. #endif