2014-10-07 11:40:43 +00:00
|
|
|
#include "socket.h"
|
2015-04-23 15:15:08 +00:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
#include <windows.h>
|
|
|
|
#else
|
2014-10-07 11:40:43 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2015-04-23 15:15:08 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
2014-10-07 11:40:43 +00:00
|
|
|
#include <errno.h>
|
|
|
|
|
2021-04-27 17:39:42 +00:00
|
|
|
ssize_t socket_fastopen_connect6(int s,const char ip[16],uint16 port,uint32_t scope_id,const char* buf,size_t len) {
|
2014-10-07 11:40:43 +00:00
|
|
|
#ifndef MSG_FASTOPEN
|
|
|
|
int r;
|
|
|
|
{
|
|
|
|
#else
|
2018-07-09 21:01:37 +00:00
|
|
|
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);
|
2018-12-14 13:54:26 +00:00
|
|
|
if (r==-1 && (errno==ENOTCONN || errno==EPIPE)) {
|
2014-10-07 11:40:43 +00:00
|
|
|
#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;
|
|
|
|
}
|