1//
2// This file is part of the aMule Project.
3//
4// Copyright (c) 2004-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5// Copyright (c) 2004-2011 Angel Vidal ( kry@amule.org )
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.
10//
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.
15//
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
24//
25
26#ifndef ECMULESOCKET_H
27#define ECMULESOCKET_H
28
29#include <wx/socket.h>		// Needed for wxSocketClient
30#include "ECSocket.h"
31
32/*! \class CECMuleSocket
33 *
34 * \brief Socket handler for External Communications (EC), wx implementation
35 *
36 */
37
38class CECMuleSocket : public CECSocket,  public wxSocketClient {
39public:
40	CECMuleSocket(bool use_events);
41	virtual ~CECMuleSocket();
42
43	bool ConnectSocket(wxIPV4address& address);
44
45 private:
46 	bool InternalConnect(uint32_t ip, uint16_t port, bool wait);
47
48 	int InternalGetLastError();
49
50	size_t InternalLastCount() { return wxSocketClient::LastCount(); };
51	bool InternalWaitOnConnect(long secs = -1, long msecs = 0) { return wxSocketClient::WaitOnConnect(secs,msecs); };
52	bool InternalWaitForWrite(long secs = -1, long msecs = 0) { return wxSocketClient::WaitForWrite(secs,msecs); };
53	bool InternalWaitForRead(long secs = -1, long msecs = 0) { return wxSocketClient::WaitForRead(secs,msecs); };
54
55	bool InternalError() { return wxSocketClient::Error(); }
56	void InternalClose() { wxSocketClient::Close(); }
57
58	void InternalRead(void* ptr, size_t len) { wxASSERT(len < 0xFFFFFFFF); wxSocketClient::Read(ptr, (wxUint32)len); };
59	void InternalWrite(const void* ptr, size_t len) { wxASSERT(len < 0xFFFFFFFF); wxSocketClient::Write(ptr, (wxUint32)len); };
60
61	bool InternalIsConnected() { return wxSocketClient::IsConnected(); }
62	void InternalDestroy() { wxSocketClient::Destroy(); }
63};
64
65#endif // ECMULESOCKET_H
66