Skip to content

Commit bfe13ff

Browse files
committed
add TCP_NODELAY on TCP transport
1 parent 586dbc1 commit bfe13ff

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

erpc_c/transports/erpc_tcp_transport.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <string>
1818
#include <sys/socket.h>
1919
#include <sys/types.h>
20+
#include <netinet/tcp.h>
2021
#include <unistd.h>
2122

2223
using namespace erpc;
@@ -142,13 +143,16 @@ erpc_status_t TCPTransport::connectClient(void)
142143
TCP_DEBUG_ERR("connecting failed");
143144
return kErpcStatus_ConnectionFailure;
144145
}
146+
147+
int set = 1;
148+
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *)&set, sizeof(int));
145149

146150
// On some systems (BSD) we can disable SIGPIPE on the socket. For others (Linux), we have to
147151
// ignore SIGPIPE.
148152
#if defined(SO_NOSIGPIPE)
149153
// Disable SIGPIPE for this socket. This will cause write() to return an EPIPE error if the
150154
// other side has disappeared instead of our process receiving a SIGPIPE.
151-
int set = 1;
155+
set = 1;
152156
if (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)) < 0)
153157
{
154158
::close(sock);
@@ -270,6 +274,8 @@ void TCPTransport::serverThread(void)
270274

271275
// Turn on reuse address option.
272276
int yes = 1;
277+
setsockopt(serverSocket, IPPROTO_TCP, TCP_NODELAY, (void *)&yes, sizeof(yes));
278+
yes = 1;
273279
int result = setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
274280
if (result < 0)
275281
{

0 commit comments

Comments
 (0)