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
|
|
@ -52,9 +52,10 @@ namespace fc {
|
|||
tcp_server();
|
||||
~tcp_server();
|
||||
|
||||
void close();
|
||||
void accept( tcp_socket& s );
|
||||
void listen( uint16_t port );
|
||||
void close();
|
||||
void accept( tcp_socket& s );
|
||||
void listen( uint16_t port );
|
||||
void listen( const fc::ip::endpoint& ep );
|
||||
uint16_t get_port()const;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -59,9 +59,12 @@ namespace fc {
|
|||
|
||||
class tcp_server::impl {
|
||||
public:
|
||||
impl(uint16_t port):
|
||||
_accept( fc::asio::default_io_service(), boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port) ){
|
||||
}
|
||||
impl(uint16_t 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(){
|
||||
try {
|
||||
_accept.close();
|
||||
|
|
@ -100,6 +103,11 @@ namespace fc {
|
|||
if( my ) delete my;
|
||||
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
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue