aboutsummaryrefslogtreecommitdiff
path: root/lib/connect.c
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@cloudflare.com>2016-02-16 12:21:22 +0000
committerDaniel Stenberg <daniel@haxx.se>2016-04-18 23:17:19 +0200
commit8f72b1366054c2466f45fd4ea6bf42d74a0400d2 (patch)
treef63ae3314dcb18f91609de77c3b4f13ef1407766 /lib/connect.c
parentdc68f2dab952a4a61d61e175d246ac2e55d75d5b (diff)
connect: implement TCP Fast Open for OS X
Diffstat (limited to 'lib/connect.c')
-rw-r--r--lib/connect.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 3f3d3f65f..a4eb56d00 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1097,7 +1097,24 @@ static CURLcode singleipconnect(struct connectdata *conn,
/* Connect TCP sockets, bind UDP */
if(!isconnected && (conn->socktype == SOCK_STREAM)) {
- rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
+ if(conn->bits.tcp_fastopen) {
+#if defined(CONNECT_DATA_IDEMPOTENT) /* OS X */
+ sa_endpoints_t endpoints;
+ endpoints.sae_srcif = 0;
+ endpoints.sae_srcaddr = NULL;
+ endpoints.sae_srcaddrlen = 0;
+ endpoints.sae_dstaddr = &addr.sa_addr;
+ endpoints.sae_dstaddrlen = addr.addrlen;
+
+ rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
+ CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT,
+ NULL, 0, NULL, NULL);
+#endif
+ }
+ else {
+ rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
+ }
+
if(-1 == rc)
error = SOCKERRNO;
}