#pragma once
-#ifdef _WIN32
-#define FOLLY_HAVE_UNIX_SOCKETS 0
-#else
-#define FOLLY_HAVE_UNIX_SOCKETS 1
-#endif
-
#ifndef _WIN32
#include <netdb.h>
#include <poll.h>
#include <WS2tcpip.h>
+using nfds_t = int;
+using sa_family_t = ADDRESS_FAMILY;
+
// We don't actually support either of these flags
// currently.
-#define MSG_DONTWAIT 1
+#define MSG_DONTWAIT 0x1000
#define MSG_EOR 0
struct msghdr {
void* msg_name;
int msg_flags;
};
+struct sockaddr_un {
+ sa_family_t sun_family;
+ char sun_path[108];
+};
+
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#define SHUT_RDWR SD_BOTH
-using nfds_t = int;
+// These are the same, but PF_LOCAL
+// isn't defined by WinSock.
+#define PF_LOCAL PF_UNIX
+
+// This isn't defined by Windows, and we need to
+// distinguish it from SO_REUSEADDR
+#define SO_REUSEPORT 0x7001
-// This is named differently in posix.
-#define sa_family_t ADDRESS_FAMILY
// Someone thought it would be a good idea
// to define a field via a macro...
#undef s_host
namespace portability {
namespace sockets {
#ifndef _WIN32
+using ::accept;
using ::bind;
using ::connect;
using ::getpeername;
bool is_fh_socket(int fh);
SOCKET fd_to_socket(int fd);
int socket_to_fd(SOCKET s);
+int translate_wsa_error(int wsaErr);
// These aren't additional overloads, but rather other functions that
// are referenced that we need to wrap, or, in the case of inet_aton,
// implement.
int accept(int s, struct sockaddr* addr, socklen_t* addrlen);
int inet_aton(const char* cp, struct in_addr* inp);
+int socketpair(int domain, int type, int protocol, int sv[2]);
// Unless you have a case where you would normally have
// to reference the function as being explicitly in the