Upstream tarball 9447
[amule.git] / src / ClientTCPSocket.h
blob41097f2acf973da97e3ae5fe6d6e522cdd48876e
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 // Handling incoming connections (up or downloadrequests)
30 #ifndef CLIENTTCPSOCKET_H
31 #define CLIENTTCPSOCKET_H
33 #include "EMSocket.h" // Needed for CEMSocket
35 class CProxyData;
37 //------------------------------------------------------------------------------
38 // CClientTCPSocket
39 //------------------------------------------------------------------------------
41 class CUpDownClient;
42 class CPacket;
43 class CTimerWnd;
45 class CClientTCPSocket : public CEMSocket
47 public:
48 CClientTCPSocket(CUpDownClient* in_client = NULL, const CProxyData *ProxyData = NULL);
49 virtual ~CClientTCPSocket();
51 void Disconnect(const wxString& strReason);
53 bool InitNetworkData();
55 bool CheckTimeOut();
57 void Safe_Delete();
59 bool ForDeletion() const { return m_ForDeletion; }
61 void OnConnect(int nErrorCode);
62 void OnSend(int nErrorCode);
63 void OnReceive(int nErrorCode);
65 void OnClose(int nErrorCode);
66 void OnError(int nErrorCode);
68 uint32 GetRemoteIP() const { return m_remoteip; }
70 CUpDownClient* GetClient() { return m_client; }
72 virtual void SendPacket(CPacket* packet, bool delpacket = true, bool controlpacket = true, uint32 actualPayloadSize = 0);
73 virtual SocketSentBytes SendControlData(uint32 maxNumberOfBytesToSend, uint32 overchargeMaxBytesToSend);
74 virtual SocketSentBytes SendFileAndControlData(uint32 maxNumberOfBytesToSend, uint32 overchargeMaxBytesToSend);
76 protected:
77 virtual bool PacketReceived(CPacket* packet);
79 private:
80 CUpDownClient* m_client;
82 bool ProcessPacket(const byte* packet, uint32 size, uint8 opcode);
83 bool ProcessExtPacket(const byte* packet, uint32 size, uint8 opcode);
84 bool ProcessED2Kv2Packet(const byte* packet, uint32 size, uint8 opcode);
85 void ResetTimeOutTimer();
86 void SetClient(CUpDownClient* client);
88 bool m_ForDeletion; // 0.30c (Creteil), set as bool
89 uint32 timeout_timer;
90 uint32 m_remoteip;
93 #endif // CLIENTTCPSOCKET_H
94 // File_checked_for_headers