Encrypter.h
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:2k
源码类别:

P2P编程

开发平台:

Visual C++

  1. // Encrypter.h: interface for the CEncrypter class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_ENCRYPTER_H__94783A72_2FDD_4F99_8776_5561FED0096D__INCLUDED_)
  5. #define AFX_ENCRYPTER_H__94783A72_2FDD_4F99_8776_5561FED0096D__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "EncryptedConnection.h"
  10. class CConnector;
  11. class CDownload;
  12. class CDownloaderFeedback;
  13. class CEncrypter  
  14. {
  15. class CUnConnectedSocket
  16. {
  17. public :
  18. CUnConnectedSocket(SOCKET socket, HANDLE hevConnecting, unsigned long laddr, short lPort, memstream &mPeerID)
  19. {
  20. m_socket = socket;
  21. m_hevConnecting = hevConnecting;
  22. m_laddr =  laddr;
  23. m_lPort = lPort;
  24. m_mPeerID.write(mPeerID, mPeerID.size());
  25. }
  26. SOCKET m_socket;
  27. HANDLE m_hevConnecting;
  28. unsigned long m_laddr;
  29. short m_lPort;
  30. memstream m_mPeerID;
  31. };
  32. public:
  33. CEncrypter(long lMaxInitiate);
  34. bool Create(CDownloaderFeedback* pMain, CConnector* pconnector, memstream& memMyid, memstream& memInfohash, 
  35. long lMaxLen, long lKeepaliveDelay);
  36. virtual ~CEncrypter();
  37. void SetMaxPeers(long lMaxInitiate);
  38. long GetMaxLen();
  39. void connection_made(SOCKET newsocket);
  40. void start_connection(string strIP, short lPort, memstream& mPeerID);
  41. void complete_connecting(long lInx);
  42. bool detele_connections_died();
  43. long send_keepalives();
  44. vector<CEncryptedConnection*> m_connections_died;
  45. vector<CEncryptedConnection*> m_connections;
  46. vector<CUnConnectedSocket*> m_unConnections;
  47. memstream m_memMyId;
  48. memstream m_memInfohash;
  49. private:
  50. void InitLocalIps();
  51. CDownloaderFeedback* m_pMain; 
  52. CConnector* m_pconnector;
  53. long m_lMaxLen;
  54. long m_lKeepaliveDelay;
  55. long m_lMaxInitiate;
  56. long m_lKeepaliveDelayLast;
  57. long m_lConnectionIDSeed;
  58. vector<long> m_vlocalIps;
  59. };
  60. #endif // !defined(AFX_ENCRYPTER_H__94783A72_2FDD_4F99_8776_5561FED0096D__INCLUDED_)