RawSocket.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:1k
源码类别:

模拟服务器

开发平台:

C/C++

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //  
  3. //  FileName    :   RawSocket.cpp
  4. //  Version     :   1.0
  5. //  Creater     :   Linsuyi
  6. //  Date        :   2002-01-09  10:46:38
  7. //  Comment     :   Tcp/ip raw socket source file
  8. //  
  9. ////////////////////////////////////////////////////////////////////////////////
  10. #include "Stdafx.h"
  11. #include "RawSocket.h"
  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////
  15. CRawSocket::CRawSocket()
  16. {
  17.     m_nSckType = SOCK_RAW;
  18.     m_nSckProto = IPPROTO_IP;
  19. }
  20. CRawSocket::~CRawSocket()
  21. {
  22. }
  23. int CRawSocket::Create()
  24. {
  25.     return CDgmSocket::Create();
  26. }
  27. int CRawSocket::SetRawProtocol(int nProtocolType)
  28. {
  29.     int nResult = false;
  30.     
  31.     if (
  32.         (nProtocolType >= 256) || 
  33.         (GetSafeHandle() != INVALID_SOCKET)
  34.     )
  35.     {
  36.         ASSERT(false);
  37.         goto Exit0;
  38.     }
  39.     
  40.     m_nSckProto = nProtocolType;
  41.     
  42.     nResult = true;
  43.     
  44. Exit0:
  45.     return nResult;
  46. }