2 // This file is part of the aMule Project.
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 )
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();
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
);
77 virtual bool PacketReceived(CPacket
* packet
);
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
93 #endif // CLIENTTCPSOCKET_H
94 // File_checked_for_headers