libowfat/socket/socket_fastopen.c

26 lines
513 B
C
Raw Normal View History

2014-10-07 11:40:43 +00:00
#include "socket.h"
#ifndef __MINGW32__
2014-10-07 11:40:43 +00:00
#include <sys/types.h>
#include <sys/socket.h>
2016-04-07 12:08:05 +00:00
#include <netinet/in.h>
2014-10-07 11:40:43 +00:00
#include <netinet/tcp.h>
#endif
2014-10-07 11:40:43 +00:00
#include <errno.h>
2016-04-07 12:08:05 +00:00
#if defined(TCP_FASTOPEN) && !defined(SOL_TCP) && defined(IPPROTO_TCP)
#define SOL_TCP IPPROTO_TCP
#endif
2014-10-07 11:40:43 +00:00
int socket_fastopen(int s) {
2015-11-11 08:04:00 +00:00
#if defined(SOL_TCP) && defined(TCP_FASTOPEN)
2014-10-07 11:40:43 +00:00
return setsockopt(s,SOL_TCP,TCP_FASTOPEN,(int[]){ 5 }, sizeof(int));
#else
#ifdef ENOPROTOOPT
errno=ENOPROTOOPT;
#else
errno=ENOSYS;
#endif
return -1;
#endif
}