Codebase list httping / debian/2.5-1 test_TFO.c
debian/2.5-1

Tree @debian/2.5-1 (Download .tar.gz)

test_TFO.c @debian/2.5-1raw · history · blame

#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;
}