Update tcp_socket listen on single endpoint
This commit is contained in:
parent
9392ca2afe
commit
a80164645f
2 changed files with 15 additions and 6 deletions
|
|
@ -55,6 +55,7 @@ namespace fc {
|
||||||
void close();
|
void close();
|
||||||
void accept( tcp_socket& s );
|
void accept( tcp_socket& s );
|
||||||
void listen( uint16_t port );
|
void listen( uint16_t port );
|
||||||
|
void listen( const fc::ip::endpoint& ep );
|
||||||
uint16_t get_port()const;
|
uint16_t get_port()const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,12 @@ namespace fc {
|
||||||
|
|
||||||
class tcp_server::impl {
|
class tcp_server::impl {
|
||||||
public:
|
public:
|
||||||
impl(uint16_t port):
|
impl(uint16_t port)
|
||||||
_accept( fc::asio::default_io_service(), boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port) ){
|
:_accept( fc::asio::default_io_service(), boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port) ){}
|
||||||
}
|
|
||||||
|
impl(const fc::ip::endpoint& ep )
|
||||||
|
:_accept( fc::asio::default_io_service(), boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4( ep.get_address()), ep.port()) ){}
|
||||||
|
|
||||||
~impl(){
|
~impl(){
|
||||||
try {
|
try {
|
||||||
_accept.close();
|
_accept.close();
|
||||||
|
|
@ -100,6 +103,11 @@ namespace fc {
|
||||||
if( my ) delete my;
|
if( my ) delete my;
|
||||||
my = new impl(port);
|
my = new impl(port);
|
||||||
}
|
}
|
||||||
|
void tcp_server::listen( const fc::ip::endpoint& ep )
|
||||||
|
{
|
||||||
|
if( my ) delete my;
|
||||||
|
my = new impl(ep);
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t tcp_server::get_port()const
|
uint16_t tcp_server::get_port()const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue