Added connection::disable_nagle()

This commit is contained in:
Davis King 2012-10-20 15:30:37 -04:00
parent 90ae4d836d
commit 4ffd067ac0
5 changed files with 48 additions and 0 deletions

View File

@ -266,6 +266,20 @@ namespace dlib
delete &connection_socket;
}
// ----------------------------------------------------------------------------------------
int connection::
disable_nagle()
{
int flag = 1;
int status = setsockopt( connection_socket, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) );
if (ret == SOCKET_ERROR)
return OTHER_ERROR;
else
return 0;
}
// ----------------------------------------------------------------------------------------
long connection::

View File

@ -141,6 +141,9 @@ namespace dlib
// as the SOCKET win the windows API.
typedef unsigned_type<void*>::type socket_descriptor_type;
int disable_nagle(
);
socket_descriptor_type get_socket_descriptor (
) const;

View File

@ -11,6 +11,7 @@
#include "sockets_kernel_2.h"
#include <fcntl.h>
#include "../set.h"
#include <netinet/tcp.h>
@ -309,6 +310,20 @@ namespace dlib
sdr(0)
{}
// ----------------------------------------------------------------------------------------
int connection::
disable_nagle()
{
int flag = 1;
if(setsockopt( connection_socket, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) ))
{
return OTHER_ERROR;
}
return 0;
}
// ----------------------------------------------------------------------------------------
long connection::

View File

@ -183,6 +183,9 @@ namespace dlib
return temp;
}
int disable_nagle(
);
typedef int socket_descriptor_type;
socket_descriptor_type get_socket_descriptor (

View File

@ -362,6 +362,19 @@ namespace dlib
- returns OTHER_ERROR if there was an error
!*/
int disable_nagle(
);
/*!
ensures
- Sets the TCP_NODELAY socket option to disable Nagle's algorithm.
This can sometimes reduce transmission latency, however, in almost
all normal cases you don't want to mess with this as the default
setting is usually appropriate.
- returns 0 upon success
- returns OTHER_ERROR if there was an error
!*/
typedef platform_specific_type socket_descriptor_type;
socket_descriptor_type get_socket_descriptor (
) const;