Unified · Split
| @@ -3,6 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | #include <errno.h> |
| 4 | 4 | #include <netdb.h> |
| 5 | 5 | #include <netinet/in.h> |
| 6 | +#include <netinet/tcp.h> | |
| 6 | 7 | #include <stdarg.h> |
| 7 | 8 | #include <stdio.h> |
| 8 | 9 | #include <stdlib.h> |
| @@ -117,7 +118,7 @@ dial(char *s) · 108 unmodified lines | ||
| 117 | 118 | { |
| 118 | 119 | struct addrinfo *r, *a, hint = {.ai_flags = AI_ADDRCONFIG, .ai_family = AF_UNSPEC, 0}; |
| 119 | 120 | char host[64], *port; |
| 120 | − int e, f; | |
| 121 | + int e, f, yes; | |
| 121 | 122 | |
| 122 | 123 | if (strncmp(s, "udp!", 4) == 0) { |
| 123 | 124 | hint.ai_socktype = SOCK_DGRAM; |
| @@ -143,11 +144,14 @@ dial(char *s) · 19 unmodified lines | ||
| 143 | 144 | return -1; |
| 144 | 145 | } |
| 145 | 146 | f = -1; |
| 147 | + yes = 1; | |
| 146 | 148 | for (a = r; a != NULL; a = a->ai_next) { |
| 147 | 149 | if ((f = socket(a->ai_family, a->ai_socktype, a->ai_protocol)) < 0) |
| 148 | 150 | continue; |
| 149 | − if (connect(f, a->ai_addr, a->ai_addrlen) == 0) | |
| 151 | + if (connect(f, a->ai_addr, a->ai_addrlen) == 0) { | |
| 152 | + setsockopt(f, SOL_TCP, TCP_NODELAY, &yes, sizeof(yes)); | |
| 150 | 153 | break; |
| 154 | + } | |
| 151 | 155 | close(f); |
| 152 | 156 | f = -1; |
| 153 | 157 | } |