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