Commit 4ffd067a authored by Davis King's avatar Davis King

Added connection::disable_nagle()

parent 90ae4d83
......@@ -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::
......
......@@ -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;
......
......@@ -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::
......
......@@ -183,6 +183,9 @@ namespace dlib
return temp;
}
int disable_nagle(
);
typedef int socket_descriptor_type;
socket_descriptor_type get_socket_descriptor (
......
......@@ -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;
......
Markdown is supported
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