Fabcoin Core  0.16.2
P2P Digital Currency
RLPXSocket.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16  */
22 #pragma once
23 
24 #include "Common.h"
25 
26 namespace dev
27 {
28 namespace p2p
29 {
30 
39 class RLPXSocket: public std::enable_shared_from_this<RLPXSocket>
40 {
41 public:
42  RLPXSocket(ba::io_service& _ioService): m_socket(_ioService) {}
43  ~RLPXSocket() { close(); }
44 
45  bool isConnected() const { return m_socket.is_open(); }
46  void close() { try { boost::system::error_code ec; m_socket.shutdown(bi::tcp::socket::shutdown_both, ec); if (m_socket.is_open()) m_socket.close(); } catch (...){} }
47  bi::tcp::endpoint remoteEndpoint() { boost::system::error_code ec; return m_socket.remote_endpoint(ec); }
48  bi::tcp::socket& ref() { return m_socket; }
49 
50 protected:
51  bi::tcp::socket m_socket;
52 };
53 
54 }
55 }
bi::tcp::endpoint remoteEndpoint()
Definition: RLPXSocket.h:47
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
Shared pointer wrapper for ASIO TCP socket.
Definition: RLPXSocket.h:39
bi::tcp::socket & ref()
Definition: RLPXSocket.h:48
bool isConnected() const
Definition: RLPXSocket.h:45
RLPXSocket(ba::io_service &_ioService)
Definition: RLPXSocket.h:42
bi::tcp::socket m_socket
Definition: RLPXSocket.h:51