aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-10-17 22:19:02 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2011-10-17 23:02:39 +0200
commite1a7ede826a0f29c1ca6a4b7ac20ff1d1264e4a2 (patch)
tree4d5b2d1437c441653668f503e4f42bfaa3079781 /examples
parent20c660caecc95b03489f870945ae9fe91c839bd3 (diff)
examples: disable Nagle in ipa-stream-*.c
To emulate how openBSC behaves.
Diffstat (limited to 'examples')
-rw-r--r--examples/ipa-stream-client.c10
-rw-r--r--examples/ipa-stream-server.c11
2 files changed, 21 insertions, 0 deletions
diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c
index 2b90f2c..9302825 100644
--- a/examples/ipa-stream-client.c
+++ b/examples/ipa-stream-client.c
@@ -6,6 +6,7 @@
#include <signal.h>
#include <sys/time.h>
#include <arpa/inet.h>
+#include <netinet/tcp.h>
#include <osmocom/core/select.h>
#include <osmocom/core/talloc.h>
@@ -177,6 +178,15 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ int on = 1, ret;
+ struct osmo_fd *ofd = osmo_stream_client_conn_get_ofd(conn);
+
+ ret = setsockopt(ofd->fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
+ if (ret < 0) {
+ LOGP(DIPATEST, LOGL_ERROR, "cannot disable Nagle\n");
+ exit(EXIT_FAILURE);
+ }
+
LOGP(DIPATEST, LOGL_NOTICE, "Entering main loop\n");
while(1) {
diff --git a/examples/ipa-stream-server.c b/examples/ipa-stream-server.c
index 5264dab..5dfd4c9 100644
--- a/examples/ipa-stream-server.c
+++ b/examples/ipa-stream-server.c
@@ -3,6 +3,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <arpa/inet.h>
+#include <netinet/tcp.h>
#include <osmocom/core/select.h>
#include <osmocom/core/talloc.h>
@@ -108,11 +110,20 @@ int main(void)
osmo_stream_server_link_set_port(server, 10000);
osmo_stream_server_link_set_accept_cb(server, accept_cb);
+ int on = 1, ret;
+ struct osmo_fd *ofd = osmo_stream_server_link_get_ofd(server);
+
if (osmo_stream_server_link_open(server) < 0) {
fprintf(stderr, "cannot open client\n");
exit(EXIT_FAILURE);
}
+ ret = setsockopt(ofd->fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
+ if (ret < 0) {
+ LOGP(DSTREAMTEST, LOGL_ERROR, "cannot disable Nagle\n");
+ exit(EXIT_FAILURE);
+ }
+
LOGP(DSTREAMTEST, LOGL_NOTICE, "Entering main loop\n");
while(1) {