fix includes
[m6w6/libmemcached] / src / libmemcached / socket.hpp
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 /* To hide the platform differences between MS Windows and Unix, I am
19 * going to use the Microsoft way and #define the Microsoft-specific
20 * functions to the unix way. Microsoft use a separate subsystem for sockets,
21 * but Unix normally just use a filedescriptor on the same functions. It is
22 * a lot easier to map back to the unix way with macros than going the other
23 * way without side effect ;-)
24 */
25 #if defined(WIN32) || defined(__MINGW32__)
26 # include "win32/wrappers.h"
27 # include "windows.hpp"
28 # define get_socket_errno() translate_windows_error()
29 #else
30 # include <unistd.h>
31 # define INVALID_SOCKET -1
32 # define SOCKET_ERROR -1
33 # define closesocket(a) close(a)
34 # define get_socket_errno() errno
35 #endif
36
37 #ifdef __cplusplus
38 static inline void memcached_close_socket(memcached_socket_t &socket_fd) {
39 closesocket(socket_fd);
40 socket_fd = INVALID_SOCKET;
41 }
42 #endif
43
44 #ifndef HAVE_MSG_NOSIGNAL
45 # define MSG_NOSIGNAL 0
46 #endif
47
48 #ifndef HAVE_MSG_DONTWAIT
49 # define MSG_DONTWAIT 0
50 #endif
51
52 #ifndef HAVE_MSG_MORE
53 # define MSG_MORE 0
54 #endif