Remove do-nothing command and add warning about it
[amule.git] / src / LibSocketWX.cpp
bloba29c295cfcb94f3293fc1d0c8cb9d6de55009c70
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2004-2011 Stu Redman ( sturedman@amule.org )
5 // Copyright (c) 2004-2011 aMule Team ( admin@amule.org / http://www.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.
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 // Implementation of amuleIPV4Address for wxWidgets sockets
28 // (Implementation for Asio is in LibSocketAsio.cpp
31 #include "LibSocket.h"
32 #include "Logger.h"
33 #include "amuleIPV4Address.h"
36 class CamuleIPV4Endpoint : public wxIPV4address {
37 public:
38 CamuleIPV4Endpoint() {}
40 CamuleIPV4Endpoint(const CamuleIPV4Endpoint & impl) : wxIPV4address(impl) {}
42 /// operator wxSockAddress& () { return * this; }
47 bool CLibSocket::Connect(amuleIPV4Address& adr, bool wait)
49 return wxSocketClient::Connect(adr.GetEndpoint(), wait);
52 bool CLibSocket::GetPeer(amuleIPV4Address& adr)
54 return wxSocketClient::GetPeer(adr.GetEndpoint());
57 void CLibSocket::SetLocal(amuleIPV4Address& local)
59 wxSocketClient::SetLocal(local.GetEndpoint());
63 CLibSocketServer::CLibSocketServer(const amuleIPV4Address &address, wxSocketFlags flags) : wxSocketServer(address.GetEndpoint(), flags)
67 CLibUDPSocket::CLibUDPSocket(amuleIPV4Address &address, wxSocketFlags flags) : wxDatagramSocket(address.GetEndpoint(), flags)
71 uint32 CLibUDPSocket::RecvFrom(amuleIPV4Address& addr, void* buf, uint32 nBytes)
73 wxDatagramSocket::RecvFrom(addr.GetEndpoint(), buf, nBytes);
74 return wxDatagramSocket::LastCount();
77 uint32 CLibUDPSocket::SendTo(const amuleIPV4Address& addr, const void* buf, uint32 nBytes)
79 wxDatagramSocket::SendTo(addr.GetEndpoint(), buf, nBytes);
80 return wxDatagramSocket::LastCount();
84 amuleIPV4Address::amuleIPV4Address()
86 m_endpoint = new CamuleIPV4Endpoint();
89 amuleIPV4Address::amuleIPV4Address(const amuleIPV4Address &a)
91 *this = a;
94 amuleIPV4Address::~amuleIPV4Address()
96 delete m_endpoint;
99 amuleIPV4Address& amuleIPV4Address::operator=(const amuleIPV4Address &a)
101 m_endpoint = new CamuleIPV4Endpoint(* a.m_endpoint);
102 return *this;
105 bool amuleIPV4Address::Hostname(const wxString& name)
107 if (name.IsEmpty()) {
108 return false;
110 return m_endpoint->Hostname(name);
113 bool amuleIPV4Address::Service(uint16 service)
115 if (service == 0) {
116 return false;
118 return m_endpoint->Service(service);
121 uint16 amuleIPV4Address::Service() const
123 return m_endpoint->Service();
126 bool amuleIPV4Address::IsLocalHost() const
128 return m_endpoint->IsLocalHost();
131 wxString amuleIPV4Address::IPAddress() const
133 return m_endpoint->IPAddress();
136 // Set address to any of the addresses of the current machine.
137 bool amuleIPV4Address::AnyAddress()
139 bool ret = m_endpoint->AnyAddress();
140 AddDebugLogLineN(logGeneral, CFormat(wxT("AnyAddress() returned %s")) % IPAddress());
141 return ret;
144 const CamuleIPV4Endpoint & amuleIPV4Address::GetEndpoint() const
146 return * m_endpoint;
149 CamuleIPV4Endpoint & amuleIPV4Address::GetEndpoint()
151 return * m_endpoint;