From 3c59eebe92f5488fdcf8b69c927a0df27b4f766c Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Thu, 27 Mar 2014 01:55:52 -0400 Subject: [PATCH] Update HTTP server api to specify network interface --- include/fc/network/http/server.hpp | 2 +- src/network/http/http_server.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/fc/network/http/server.hpp b/include/fc/network/http/server.hpp index 711ea50..a90764e 100644 --- a/include/fc/network/http/server.hpp +++ b/include/fc/network/http/server.hpp @@ -45,7 +45,7 @@ namespace fc { namespace http { fc::shared_ptr my; }; - void listen( uint16_t p ); + void listen( const fc::ip::endpoint& p ); /** * Set the callback to be called for every http request made. diff --git a/src/network/http/http_server.cpp b/src/network/http/http_server.cpp index 1f7578d..678f4db 100644 --- a/src/network/http/http_server.cpp +++ b/src/network/http/http_server.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ namespace fc { namespace http { { public: impl(){} - impl(uint16_t p ) { + impl(const fc::ip::endpoint& p ) { tcp_serv.listen(p); accept_complete = fc::async([this](){ this->accept_loop(); }); } @@ -86,14 +87,14 @@ namespace fc { namespace http { server::server(){} - server::server( uint16_t port ) :my( new impl(port) ){} + server::server( uint16_t port ) :my( new impl(fc::ip::endpoint( fc::ip::address(),port)) ){} server::server( server&& s ):my(fc::move(s.my)){} server& server::operator=(server&& s) { fc_swap(my,s.my); return *this; } server::~server(){} - void server::listen( uint16_t p ) { + void server::listen( const fc::ip::endpoint& p ) { my.reset( new impl(p) ); }