diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index b3b3d5bf3..64d10b172 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -396,7 +396,7 @@ void Host::runAcceptor() clog(NetConnect) << "Listening on local port " << m_listenPort << " (public: " << m_tcpPublic << ")"; m_accepting = true; - auto socket = make_shared(new bi::tcp::socket(m_ioService)); + auto socket = make_shared(m_ioService); m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec) { m_accepting = false; @@ -552,7 +552,7 @@ void Host::connect(std::shared_ptr const& _p) bi::tcp::endpoint ep(_p->endpoint); clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id(); - auto socket = make_shared(new bi::tcp::socket(m_ioService)); + auto socket = make_shared(m_ioService); socket->ref().async_connect(ep, [=](boost::system::error_code const& ec) { _p->m_lastAttempted = std::chrono::system_clock::now(); diff --git a/libp2p/RLPXSocket.h b/libp2p/RLPXSocket.h index 58613bf82..171a7b35b 100644 --- a/libp2p/RLPXSocket.h +++ b/libp2p/RLPXSocket.h @@ -39,8 +39,7 @@ namespace p2p class RLPXSocket: public std::enable_shared_from_this { public: - /// Constructor. Dereferences and takes ownership of _socket. - RLPXSocket(bi::tcp::socket* _socket): m_socket(std::move(*_socket)) {} + RLPXSocket(ba::io_service& _ioService): m_socket(_ioService) {} ~RLPXSocket() { close(); } bool isConnected() const { return m_socket.is_open(); }