Discussion:
boost asio asynchron ftp server
(too old to reply)
Christer Borgqvist
2016-10-15 11:58:38 UTC
Permalink
Hi, I'm trying to write an FTP server on the basis of http server
examples from Boost, it must be able to receive up to 2000 connections
simultaneously, but it does not matter how I do it freezes after about
150 connections
so I was wondering from which of the examples I'll start from?.

/Christer


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Vinnie Falco
2016-10-15 12:49:22 UTC
Permalink
On Sat, Oct 15, 2016 at 7:58 AM, Christer Borgqvist
it freezes after about 150 connections
Are you running a debug build? Are you saying that the HTTP server
example in Boost freezes after 150 connections? What operating system
/ environment? Have you made changes to the example? Is your code on
GitHub?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Christer Borgqvist
2016-10-15 16:30:39 UTC
Permalink
Post by Christer Borgqvist
Hi, I'm trying to write an FTP server on the basis of http server
examples from Boost, it must be able to receive up to 2000 connections
simultaneously, but it does not matter how I do it freezes after about
150 connections
so I was wondering from which of the examples I'll start from?.
/Christer
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
I run on debug build on Fedora 23 and a Release Build on RHEL6,
the changes is in the connection class the rest is the same,
the client connect and the server going into a async_read, and then the
next client connect and so on, the server freezes after more or less 150
connection, more is not more than 20 to 30 connections, now i try to add
a deadline timer to close connections.
the code is not in GitHub.

/Christer



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Christer Borgqvist
2016-10-15 16:31:22 UTC
Permalink
Post by Christer Borgqvist
Hi, I'm trying to write an FTP server on the basis of http server
examples from Boost, it must be able to receive up to 2000 connections
simultaneously, but it does not matter how I do it freezes after about
150 connections
so I was wondering from which of the examples I'll start from?.
/Christer
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
I run on debug build on Fedora 23 and a Release Build on RHEL6,
the changes is in the connection class the rest is the same,
the client connect and the server going into a async_read, and then the
next client connect and so on, the server freezes after more or less 150
connection, more is not more than 20 to 30 connections, now i try to add
a deadline timer to close connections.
the code os not in GitHub.

/Christer



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Svante Karlsson
2016-10-15 16:42:28 UTC
Permalink
Most likely the error is in your code. asio in itself has no problem
scaling to thousands(and more) connections. Take care and either handle
your connections from a single thread or pay attention to locking between
threads.

The easier solution is single threaded...





2016-10-15 18:31 GMT+02:00 Christer Borgqvist <
Post by Christer Borgqvist
Post by Christer Borgqvist
Hi, I'm trying to write an FTP server on the basis of http server
examples from Boost, it must be able to receive up to 2000 connections
simultaneously, but it does not matter how I do it freezes after about
150 connections
so I was wondering from which of the examples I'll start from?.
/Christer
------------------------------------------------------------
------------------
Post by Christer Borgqvist
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
I run on debug build on Fedora 23 and a Release Build on RHEL6,
the changes is in the connection class the rest is the same,
the client connect and the server going into a async_read, and then the
next client connect and so on, the server freezes after more or less 150
connection, more is not more than 20 to 30 connections, now i try to add
a deadline timer to close connections.
the code os not in GitHub.
/Christer
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Gruenke,Matt
2016-10-16 02:30:30 UTC
Permalink
I second this. Either use a strand per connection (whereupon all operations on the connection are serialized via the strand), or make it single-threaded.

If your eventual goal is to make it multi-threaded, then you’d be better off using strands from the outset.


Matt

From: Svante Karlsson [mailto:***@csi.se]
Sent: Saturday, October 15, 2016 12:42
To: Unname
Subject: Re: [asio-users] boost asio asynchron ftp server

Most likely the error is in your code. asio in itself has no problem scaling to thousands(and more) connections. Take care and either handle your connections from a single thread or pay attention to locking between threads.

The easier solution is single threaded...
Post by Christer Borgqvist
Hi, I'm trying to write an FTP server on the basis of http server
examples from Boost, it must be able to receive up to 2000 connections
simultaneously, but it does not matter how I do it freezes after about
150 connections
so I was wondering from which of the examples I'll start from?.
/Christer
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot<https://urldefense.proofpoint.com/v2/url?u=http-3A__sdm.link_slashdot&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=YrJ1Q9ZB-i0eKOw3_PbXCyzviCkHR-iqIMMwgO2Qjfw&e=>
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_asio-2Dusers&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=kKdNUtiFy8tgpPXFtAbRP2oLzUwNS_QKBUTekrilMys&e=>
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio<https://urldefense.proofpoint.com/v2/url?u=http-3A__think-2Dasync.com_Asio_WhoIsUsingAsio&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=en_WIVVMH4aFV1gsu8kq58SuZ-O2FlL8GRNvcu5ZX3M&e=>
I run on debug build on Fedora 23 and a Release Build on RHEL6,
the changes is in the connection class the rest is the same,
the client connect and the server going into a async_read, and then the
next client connect and so on, the server freezes after more or less 150
connection, more is not more than 20 to 30 connections, now i try to add
a deadline timer to close connections.
the code os not in GitHub.

/Christer



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot<https://urldefense.proofpoint.com/v2/url?u=http-3A__sdm.link_slashdot&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=YrJ1Q9ZB-i0eKOw3_PbXCyzviCkHR-iqIMMwgO2Qjfw&e=>
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net<mailto:asio-***@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/asio-users<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_asio-2Dusers&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=kKdNUtiFy8tgpPXFtAbRP2oLzUwNS_QKBUTekrilMys&e=>
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio<https://urldefense.proofpoint.com/v2/url?u=http-3A__think-2Dasync.com_Asio_WhoIsUsingAsio&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=en_WIVVMH4aFV1gsu8kq58SuZ-O2FlL8GRNvcu5ZX3M&e=>


________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.
Christer Borgqvist
2016-10-16 06:50:18 UTC
Permalink
Post by Gruenke,Matt
I second this. Either use a strand per connection (whereupon all
operations on the connection are serialized via the strand), or make it
single-threaded.
If your eventual goal is to make it multi-threaded, then you’d be better
off using strands from the outset.
Matt
*Sent:* Saturday, October 15, 2016 12:42
*To:* Unname
*Subject:* Re: [asio-users] boost asio asynchron ftp server
Most likely the error is in your code. asio in itself has no problem
scaling to thousands(and more) connections. Take care and either handle
your connections from a single thread or pay attention to locking
between threads.
The easier solution is single threaded...
2016-10-15 18:31 GMT+02:00 Christer Borgqvist
Post by Christer Borgqvist
Hi, I'm trying to write an FTP server on the basis of http server
examples from Boost, it must be able to receive up to 2000 connections
simultaneously, but it does not matter how I do it freezes after about
150 connections
so I was wondering from which of the examples I'll start from?.
/Christer
------------------------------------------------------------------------------
Post by Christer Borgqvist
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
<https://urldefense.proofpoint.com/v2/url?u=http-3A__sdm.link_slashdot&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=YrJ1Q9ZB-i0eKOw3_PbXCyzviCkHR-iqIMMwgO2Qjfw&e=>
Post by Christer Borgqvist
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_asio-2Dusers&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=kKdNUtiFy8tgpPXFtAbRP2oLzUwNS_QKBUTekrilMys&e=>
Post by Christer Borgqvist
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
<https://urldefense.proofpoint.com/v2/url?u=http-3A__think-2Dasync.com_Asio_WhoIsUsingAsio&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=en_WIVVMH4aFV1gsu8kq58SuZ-O2FlL8GRNvcu5ZX3M&e=>
I run on debug build on Fedora 23 and a Release Build on RHEL6,
the changes is in the connection class the rest is the same,
the client connect and the server going into a async_read, and then the
next client connect and so on, the server freezes after more or less 150
connection, more is not more than 20 to 30 connections, now i try to add
a deadline timer to close connections.
the code os not in GitHub.
/Christer
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
<https://urldefense.proofpoint.com/v2/url?u=http-3A__sdm.link_slashdot&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=YrJ1Q9ZB-i0eKOw3_PbXCyzviCkHR-iqIMMwgO2Qjfw&e=>
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_asio-2Dusers&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=kKdNUtiFy8tgpPXFtAbRP2oLzUwNS_QKBUTekrilMys&e=>
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
<https://urldefense.proofpoint.com/v2/url?u=http-3A__think-2Dasync.com_Asio_WhoIsUsingAsio&d=DQMFaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=VhIBU6ncUQoMafVUqG8TjKbuDohjXo_1oEvOBKGy_DA&m=mfOooUEaH9ViAxW8LO-eFRyMOYbSAUD3d5dFm_4ySVE&s=en_WIVVMH4aFV1gsu8kq58SuZ-O2FlL8GRNvcu5ZX3M&e=>
------------------------------------------------------------------------
This e-mail contains privileged and confidential information intended
for the use of the addressees named above. If you are not the intended
recipient of this e-mail, you are hereby notified that you must not
disseminate, copy or take any action in respect of any information
contained in it. If you have received this e-mail in error, please
notify the sender immediately by e-mail and immediately destroy this
e-mail and its attachments.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Here are part of my code Server and connection

server::server() : signals_(io_service_),
acceptor_(io_service_),
new_connection() {

signals_.add(SIGINT);
signals_.add(SIGTERM);
//#if defined(SIGQUIT)
signals_.add(SIGQUIT);
signals_.add(SIGTERM);
signals_.add(SIGCHLD);
//#endif // defined(SIGQUIT)
signals_.async_wait(boost::bind(&server::handle_stop, this));

resolver(io_service_pool_.get_io_service());
boost::asio::ip::tcp::resolver resolver(io_service_);
boost::asio::ip::tcp::resolver::query query("0.0.0.0", g_port);
boost::asio::ip::tcp::endpoint endpoint =
*resolver.resolve(query);
acceptor_.open(endpoint.protocol());

acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
acceptor_.bind(endpoint);
acceptor_.listen();
start_accept();


}
void server::run()
{
if ( g_debug )
INFO << "server running";

// Create a pool of threads to run all of the io_services.
std::vector<boost::shared_ptr<boost::thread> > threads;
for (std::size_t i = 0; i < g_thread_pool_size; ++i)
{
boost::shared_ptr<boost::thread> thread(new boost::thread(
boost::bind(&boost::asio::io_service::run, &io_service_)));
threads.push_back(thread);
}

// Wait for all threads in the pool to exit.
for (std::size_t i = 0; i < threads.size(); ++i)
threads[i]->join();
}
void server::start_accept()
{
new_connection.reset(new connection(io_service_));
//new_connection.reset(new
connection(io_service_pool_.get_io_service()));
acceptor_.async_accept(new_connection->socket(),
boost::bind(&server::handle_accept, this,
boost::asio::placeholders::error));
}

void server::handle_accept(const boost::system::error_code& e)
{
try {
if (!e)
{
if ( g_debug )
INFO << "ACCEPT INCOMMING";

new_connection->start();
}

start_accept();
}
catch (...) {
WARN << "Unhandle exception in handle_accept";
}
}

void server::handle_stop()
{
io_service_.stop();
//io_service_pool_.stop();
}
}


and connection
connection::connection(boost::asio::io_service& io_service)
: _io_service(io_service),
socket_(_io_service),
strand_(_io_service),
deadline_(_io_service),
timeout(g_timeout),
m_have_data_connection(false),
acceptor(0)
{
deadline_.expires_at(boost::posix_time::pos_infin);
m_welcome = "220 FTP Server \r\n";
OnDataConnectionCallback =
boost::bind(&connection::OnDataConnectionDone, this, _1);
/// Start the persistent actor that checks for deadline expiry.



}
void connection::start()
{
check_deadline(&deadline_);//
m_local_ip_address =
socket_.lowest_layer().local_endpoint().address().to_string();
boost::system::error_code error;
try {
if ( g_debug ) {
INFO << "Connected, sending welcome message..." <<
m_welcome;
}

boost::asio::async_write(socket_,
boost::asio::buffer(m_welcome, m_welcome.size()),
strand_.wrap(
boost::bind(&connection::handle_login,
shared_from_this(),
boost::asio::placeholders::error)));
}
void connection::handle_login(boost::system::error_code e) {
if (!e) {
deadline_.expires_from_now(timeout);
if ( acceptor != 0 )
acceptor = 0;

boost::asio::async_read_until(socket_, buffer_, "\r\n",
strand_.wrap(
boost::bind(&connection::handle_read,
shared_from_this(),
boost::asio::placeholders::error,

boost::asio::placeholders::bytes_transferred)));
}
}


The problem is that if the client not send anyting the async_read will
hang, and if a lot of client do the same for some reason then there is
for me a max connection of about 150.
/Christer


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Gruenke,Matt
2016-10-16 07:33:22 UTC
Permalink
I don't see the connection calling async_wait(). To use connection::deadline_, you must do that.

Also, I wonder what effects you see, if you run it with one thread (how many does it currently use?) and if you disable your calls to signals_.add() and replace signals_.async_wait() with constructing io_service::work on the service.


Matt


-----Original Message-----
From: Christer Borgqvist [mailto:***@bredband.net]
Sent: Sunday, October 16, 2016 2:50
To: asio-***@lists.sourceforge.net
Subject: Re: [asio-users] boost asio asynchron ftp server


The problem is that if the client not send anyting the async_read will
hang, and if a lot of client do the same for some reason then there is
for me a max connection of about 150.
/Christer



________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Christer Borgqvist
2016-10-16 09:26:26 UTC
Permalink
Post by Gruenke,Matt
I don't see the connection calling async_wait(). To use connection::deadline_, you must do that.
Also, I wonder what effects you see, if you run it with one thread (how many does it currently use?) and if you disable your calls to signals_.add() and replace signals_.async_wait() with constructing io_service::work on the service.
Matt
-----Original Message-----
Sent: Sunday, October 16, 2016 2:50
Subject: Re: [asio-users] boost asio asynchron ftp server
The problem is that if the client not send anyting the async_read will
hang, and if a lot of client do the same for some reason then there is
for me a max connection of about 150.
/Christer
________________________________
This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
First Thanks for all the answers,

I call the async_wait in function call check_deadline(&deadline_); in
connection::start, i`ll try to disable signals_.add with
signals_async_wait in the constructor.

void connection::check_deadline(boost::asio::deadline_timer
*deadline_)
{

if (deadline_->expires_at() <=
deadline_timer::traits_type::now())
{
INFO << "Socket timout";

deadline_->async_wait(boost::bind(&connection::handle_write,
shared_from_this(), boost::asio::placeholders::error));
return;
}
deadline_->async_wait(boost::bind(&connection::check_deadline,
shared_from_this(), deadline_ ));

}
/Christer


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Gruenke,Matt
2016-10-16 17:07:03 UTC
Permalink
This isn't the way I normally use timers, but I think it's okay except for the fact that any connection callback that's posted/dispatched to the io_service or that's passed to an async function should be wrapped by the strand.

BTW, why does check_deadline() even need a pointer to asio::deadline_timer? That's unnecessary, since it's already a member of this. On that note, it seems your deadline_ parmeter is shadowing this->deadline_. Most people use the trailing underscore to denote a member, so it's odd to have that in a parameter name, even if you didn't have a member of the same name.


Matt


-----Original Message-----
From: Christer Borgqvist [mailto:***@bredband.net]
Sent: Sunday, October 16, 2016 5:26
To: asio-***@lists.sourceforge.net
Subject: Re: [asio-users] boost asio asynchron ftp server

First Thanks for all the answers,

I call the async_wait in function call check_deadline(&deadline_); in connection::start, i`ll try to disable signals_.add with signals_async_wait in the constructor.

void connection::check_deadline(boost::asio::deadline_timer
*deadline_)
{

if (deadline_->expires_at() <=
deadline_timer::traits_type::now())
{
INFO << "Socket timout";

deadline_->async_wait(boost::bind(&connection::handle_write,
shared_from_this(), boost::asio::placeholders::error));
return;
}
deadline_->async_wait(boost::bind(&connection::check_deadline,
shared_from_this(), deadline_ ));

}
/Christer


________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Christer Borgqvist
2016-10-21 07:34:36 UTC
Permalink
Post by Gruenke,Matt
This isn't the way I normally use timers, but I think it's okay except for the fact that any connection callback that's posted/dispatched to the io_service or that's passed to an async function should be wrapped by the strand.
BTW, why does check_deadline() even need a pointer to asio::deadline_timer? That's unnecessary, since it's already a member of this. On that note, it seems your deadline_ parmeter is shadowing this->deadline_. Most people use the trailing underscore to denote a member, so it's odd to have that in a parameter name, even if you didn't have a member of the same name.
Matt
-----Original Message-----
Sent: Sunday, October 16, 2016 5:26
Subject: Re: [asio-users] boost asio asynchron ftp server
First Thanks for all the answers,
I call the async_wait in function call check_deadline(&deadline_); in connection::start, i`ll try to disable signals_.add with signals_async_wait in the constructor.
void connection::check_deadline(boost::asio::deadline_timer
*deadline_)
{
if (deadline_->expires_at() <=
deadline_timer::traits_type::now())
{
INFO << "Socket timout";
deadline_->async_wait(boost::bind(&connection::handle_write,
shared_from_this(), boost::asio::placeholders::error));
return;
}
deadline_->async_wait(boost::bind(&connection::check_deadline,
shared_from_this(), deadline_ ));
}
/Christer
________________________________
This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Thanks for Your replay,
I`ll follow your suggestions.
/Christer


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

Loading...