php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #67170
Patch set_socket_options revision 2014-05-01 17:12 UTC by yarekt at gmail dot com

Patch set_socket_options for stomp Bug #67170

Patch version 2014-05-01 17:12 UTC

Return to Bug #67170 | Download this patch
Patch Revisions:

Developer: yarekt@gmail.com

commit fb9973d0b2a42a1308fb35adad513fcd6b152d54
Author: Yarek Tyshchenko <yarekt@gmail.com>
Date:   Thu May 1 17:48:07 2014 +0100

    Disable Nagle's Algorithm by adding TCP_NODELAY option to the socket

diff --git a/stomp.c b/stomp.c
index a72dfeb..a102986 100644
--- a/stomp.c
+++ b/stomp.c
@@ -27,6 +27,7 @@
 #include "ext/standard/php_smart_str.h"
 #include "stomp.h"
 #include "php_stomp.h"
+#include <netinet/tcp.h>
 
 #define RETURN_READ_FRAME_FAIL { stomp_free_frame(f); return NULL; }
 
@@ -173,6 +174,8 @@ int stomp_connect(stomp_t *stomp, const char *host, unsigned short port TSRMLS_D
 		stomp_set_error(stomp, error, errno, NULL);
 		return 0;
 	}
+	int flag = 1;
+	setsockopt(stomp->fd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
 
 	size = sizeof(stomp->localaddr);
 	memset(&stomp->localaddr, 0, size);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC