Encrypter.h
资源名称:GGBT.rar [点击查看]
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:2k
源码类别:
P2P编程
开发平台:
Visual C++
- // Encrypter.h: interface for the CEncrypter class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_ENCRYPTER_H__94783A72_2FDD_4F99_8776_5561FED0096D__INCLUDED_)
- #define AFX_ENCRYPTER_H__94783A72_2FDD_4F99_8776_5561FED0096D__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "EncryptedConnection.h"
- class CConnector;
- class CDownload;
- class CDownloaderFeedback;
- class CEncrypter
- {
- class CUnConnectedSocket
- {
- public :
- CUnConnectedSocket(SOCKET socket, HANDLE hevConnecting, unsigned long laddr, short lPort, memstream &mPeerID)
- {
- m_socket = socket;
- m_hevConnecting = hevConnecting;
- m_laddr = laddr;
- m_lPort = lPort;
- m_mPeerID.write(mPeerID, mPeerID.size());
- }
- SOCKET m_socket;
- HANDLE m_hevConnecting;
- unsigned long m_laddr;
- short m_lPort;
- memstream m_mPeerID;
- };
- public:
- CEncrypter(long lMaxInitiate);
- bool Create(CDownloaderFeedback* pMain, CConnector* pconnector, memstream& memMyid, memstream& memInfohash,
- long lMaxLen, long lKeepaliveDelay);
- virtual ~CEncrypter();
- void SetMaxPeers(long lMaxInitiate);
- long GetMaxLen();
- void connection_made(SOCKET newsocket);
- void start_connection(string strIP, short lPort, memstream& mPeerID);
- void complete_connecting(long lInx);
- bool detele_connections_died();
- long send_keepalives();
- vector<CEncryptedConnection*> m_connections_died;
- vector<CEncryptedConnection*> m_connections;
- vector<CUnConnectedSocket*> m_unConnections;
- memstream m_memMyId;
- memstream m_memInfohash;
- private:
- void InitLocalIps();
- CDownloaderFeedback* m_pMain;
- CConnector* m_pconnector;
- long m_lMaxLen;
- long m_lKeepaliveDelay;
- long m_lMaxInitiate;
- long m_lKeepaliveDelayLast;
- long m_lConnectionIDSeed;
- vector<long> m_vlocalIps;
- };
- #endif // !defined(AFX_ENCRYPTER_H__94783A72_2FDD_4F99_8776_5561FED0096D__INCLUDED_)