Commit b7387da4 authored by Dan Notestein's avatar Dan Notestein
Browse files

Try increasing receive buffer size.

parent 062b53f4
......@@ -20,6 +20,7 @@ namespace fc {
void enable_keep_alives(const fc::microseconds& interval);
void set_io_hooks(tcp_socket_io_hooks* new_hooks);
void set_reuse_address(bool enable = true); // set SO_REUSEADDR
int set_receive_buffer_size(int new_receive_buffer_size);
int set_send_buffer_size(int new_send_buffer_size);
bool get_no_delay();
void set_no_delay(bool no_delay_flag);
......@@ -27,11 +28,7 @@ namespace fc {
fc::ip::endpoint local_endpoint() const;
using istream::get;
void get( char& c )
{
read( &c, 1 );
}
void get( char& c ) { read( &c, 1 ); }
/// istream interface
/// @{
......@@ -76,6 +73,7 @@ namespace fc {
void close();
void accept( tcp_socket& s );
void set_reuse_address(bool enable = true); // set SO_REUSEADDR, call before listen
int set_receive_buffer_size(int new_receive_buffer_size);
int set_send_buffer_size(int new_send_buffer_size);
bool get_no_delay();
void set_no_delay(bool no_delay_flag);
......
......@@ -236,6 +236,23 @@ namespace fc {
#endif // __APPLE__
}
int tcp_socket::set_receive_buffer_size(int new_receive_buffer_size)
{
//read and log old receive_buffer_size
boost::asio::socket_base::receive_buffer_size old_receive_buffer_reading;
my->_sock.get_option(old_receive_buffer_reading);
wdump((old_receive_buffer_reading.value()));
boost::asio::socket_base::receive_buffer_size option(new_receive_buffer_size);
my->_sock.set_option(option);
//read new value and log receive_buffer_size
boost::asio::socket_base::receive_buffer_size new_receive_buffer_reading;
my->_sock.get_option(new_receive_buffer_reading);
wdump((new_receive_buffer_reading.value()));
return new_receive_buffer_reading.value();
}
int tcp_socket::set_send_buffer_size(int new_send_buffer_size)
{
//read and log old send_buffer_size
......@@ -332,6 +349,26 @@ namespace fc {
#endif // __APPLE__
}
int tcp_server::set_receive_buffer_size(int new_receive_buffer_size)
{
if( !my )
my = new impl;
//read and log old receive_buffer_size
boost::asio::socket_base::receive_buffer_size old_receive_buffer_reading;
my->_accept.get_option(old_receive_buffer_reading);
wdump((old_receive_buffer_reading.value()));
boost::asio::socket_base::receive_buffer_size option(new_receive_buffer_size);
my->_accept.set_option(option);
//read and log new receive_buffer_size
boost::asio::socket_base::receive_buffer_size new_receive_buffer_reading;
my->_accept.get_option(new_receive_buffer_reading);
wdump((new_receive_buffer_reading.value()));
return new_receive_buffer_reading.value();
}
int tcp_server::set_send_buffer_size(int new_send_buffer_size)
{
if( !my )
......
......@@ -4436,6 +4436,7 @@ namespace graphene { namespace net {
try
{
_tcp_server.accept( new_peer->get_socket() );
new_peer->get_socket().set_receive_buffer_size(MAX_MESSAGE_SIZE);
new_peer->get_socket().set_send_buffer_size(MAX_MESSAGE_SIZE);
idump((new_peer->get_socket().get_no_delay()));
new_peer->get_socket().set_no_delay(true);
......@@ -4782,6 +4783,8 @@ namespace graphene { namespace net {
}
_tcp_server.set_reuse_address();
int server_receive_buffer_size = _tcp_server.set_receive_buffer_size(MAX_MESSAGE_SIZE);
idump((server_receive_buffer_size));
int server_send_buffer_size = _tcp_server.set_send_buffer_size(MAX_MESSAGE_SIZE);
idump((server_send_buffer_size));
idump((_tcp_server.get_no_delay()));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment