2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
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
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.
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
37 //------------------------------------------------------------------------------
39 //------------------------------------------------------------------------------
45 class CClientTCPSocket
: public CEMSocket
48 CClientTCPSocket(CUpDownClient
* in_client
= NULL
, const CProxyData
*ProxyData
= NULL
);
49 virtual ~CClientTCPSocket();
51 void Disconnect(const wxString
& strReason
);
53 bool InitNetworkData();
58 void Safe_Delete_Client();
60 void OnConnect(int nErrorCode
);
61 void OnSend(int nErrorCode
);
62 void OnReceive(int nErrorCode
);
64 void OnClose(int nErrorCode
);
65 void OnError(int nErrorCode
);
67 uint32
GetRemoteIP() const { return m_remoteip
; }
69 CUpDownClient
* GetClient() { return m_client
; }
71 virtual void SendPacket(CPacket
* packet
, bool delpacket
= true, bool controlpacket
= true, uint32 actualPayloadSize
= 0);
72 virtual SocketSentBytes
SendControlData(uint32 maxNumberOfBytesToSend
, uint32 overchargeMaxBytesToSend
);
73 virtual SocketSentBytes
SendFileAndControlData(uint32 maxNumberOfBytesToSend
, uint32 overchargeMaxBytesToSend
);
76 virtual bool PacketReceived(CPacket
* packet
);
79 CUpDownClient
* m_client
;
81 bool ProcessPacket(const uint8_t* packet
, uint32 size
, uint8 opcode
);
82 bool ProcessExtPacket(const uint8_t* packet
, uint32 size
, uint8 opcode
);
83 bool ProcessED2Kv2Packet(const uint8_t* packet
, uint32 size
, uint8 opcode
);
84 void ResetTimeOutTimer();
85 void SetClient(CUpDownClient
* client
);
91 #endif // CLIENTTCPSOCKET_H
92 // File_checked_for_headers