forked from yhtsnda/httping
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_TFO.c
More file actions
30 lines (26 loc) · 769 Bytes
/
Copy pathtest_TFO.c
File metadata and controls
30 lines (26 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int main(void) {
int sfd = 0;
int qlen = 5;
if ((sfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
fprintf(stderr, "socket(): %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
#ifdef TCP_FASTOPEN
if (setsockopt(sfd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)) == -1) {
fprintf(stderr, "setsockopt(): %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
#else
fprintf(stderr, "TCP_FASTOPEN: undefined\n");
return EXIT_FAILURE;
#endif
return EXIT_SUCCESS;
}