Upstream tarball 20080405
[amule.git] / src / libs / ec / cpp / ECMuleSocket.h
blobbb7996a4bd2f5c374007f96d63f544142b32eed4
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2004-2008 Angel Vidal Veiga ( kry@users.sourceforge.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
26 #ifndef ECMULESOCKET_H
27 #define ECMULESOCKET_H
29 #include <wx/socket.h> // Needed for wxSocketClient
30 #include "ECSocket.h"
32 /*! \class CECMuleSocket
34 * \brief Socket handler for External Communications (EC), wx implementation
38 class CECMuleSocket : public CECSocket, public wxSocketClient {
39 public:
40 CECMuleSocket(bool use_events);
41 virtual ~CECMuleSocket();
43 bool ConnectSocket(wxIPV4address& address);
45 private:
46 bool InternalConnect(uint32_t ip, uint16_t port, bool wait);
48 int InternalGetLastError();
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::WaitForRead(secs,msecs); };
53 bool InternalWaitForRead(long secs = -1, long msecs = 0) { return wxSocketClient::WaitForWrite(secs,msecs); };
55 bool InternalError() { return wxSocketClient::Error(); }
56 void InternalClose() { wxSocketClient::Close(); }
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); };
61 bool InternalIsConnected() { return wxSocketClient::IsConnected(); }
62 void InternalDestroy() { wxSocketClient::Destroy(); }
65 #endif // ECMULESOCKET_H