File: socket_fastopen_connect6.c

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (28 lines) | stat: -rw-r--r-- 675 bytes parent folder | download
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
#include "socket.h"
#ifdef __MINGW32__
#include <windows.h>
#else
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#endif
#include <errno.h>

ssize_t socket_fastopen_connect6(int s,const char ip[16],uint16 port,uint32_t scope_id,const char* buf,size_t len) {
#ifndef MSG_FASTOPEN
  int r;
  {
#else
  int r;
  if (len)
    r=socket_send6_flag(s,buf,len,ip,port,scope_id,MSG_FASTOPEN);
  else
    r=socket_connect6(s,ip,port,scope_id);
  if (r==-1 && (errno==ENOTCONN || errno==EPIPE)) {
#endif
    /* apparently the kernel does not support TCP fast open */
    r=socket_connect6(s,ip,port,scope_id);
    if (r==0) return write(s,buf,len);
  }
  return r;
}