mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Move sources to src and build objs in obj.
This commit is contained in:
36
src/PeerDoor.cpp
Normal file
36
src/PeerDoor.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "PeerDoor.h"
|
||||
#include "Config.h"
|
||||
#include <boost/bind.hpp>
|
||||
//#include <boost/log/trivial.hpp>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
using namespace boost::asio::ip;
|
||||
|
||||
PeerDoor::PeerDoor(boost::asio::io_service& io_service) :
|
||||
mAcceptor(io_service, tcp::endpoint(tcp::v4(), theConfig.PEER_PORT))
|
||||
{
|
||||
cout << "Opening peer door on port: " << theConfig.PEER_PORT << endl;
|
||||
startListening();
|
||||
}
|
||||
|
||||
void PeerDoor::startListening()
|
||||
{
|
||||
Peer::pointer new_connection = Peer::create(mAcceptor.get_io_service());
|
||||
|
||||
mAcceptor.async_accept(new_connection->getSocket(),
|
||||
boost::bind(&PeerDoor::handleConnect, this, new_connection,
|
||||
boost::asio::placeholders::error));
|
||||
}
|
||||
|
||||
void PeerDoor::handleConnect(Peer::pointer new_connection,
|
||||
const boost::system::error_code& error)
|
||||
{
|
||||
if(!error)
|
||||
{
|
||||
new_connection->connected(error);
|
||||
}
|
||||
else cout << "Error: " << error; // BOOST_LOG_TRIVIAL(info) << "Error: " << error;
|
||||
|
||||
startListening();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user