"Fossies" - the Fresh Open Source Software Archive

Member "HTTPing-2.9/test_TFO.c" (29 Oct 2022, 769 Bytes) of package /linux/www/HTTPing-2.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include <stdio.h>
    2 #include <string.h>
    3 #include <errno.h>
    4 #include <stdlib.h>
    5 
    6 #include <sys/types.h>
    7 #include <sys/socket.h>
    8 #include <netinet/in.h>
    9 #include <netinet/tcp.h>
   10 
   11 int main(void) {
   12         int sfd = 0;
   13         int qlen = 5;
   14 
   15         if ((sfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
   16                 fprintf(stderr, "socket(): %s\n", strerror(errno));
   17                 exit(EXIT_FAILURE);
   18         }
   19 
   20 #ifdef TCP_FASTOPEN
   21         if (setsockopt(sfd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)) == -1) {
   22                 fprintf(stderr, "setsockopt(): %s\n", strerror(errno));
   23                 exit(EXIT_FAILURE);
   24         }
   25 #else
   26         fprintf(stderr, "TCP_FASTOPEN: undefined\n");
   27         return EXIT_FAILURE;
   28 #endif
   29         return EXIT_SUCCESS;
   30 }