1 /* 2 Copyright (c) 2008, 2021, Oracle and/or its affiliates. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef NDB_SOCKET_H 26 #define NDB_SOCKET_H 27 28 #ifdef _WIN32 29 #include <ndb_socket_win32.h> 30 #else 31 #include <ndb_socket_posix.h> 32 #endif 33 34 static inline 35 void ndb_socket_close(ndb_socket_t sock, bool with_reset = false) 36 { 37 if (with_reset) 38 { 39 // Force hard reset of the socket by turning on linger 40 // with timeout 0 41 struct linger hard_reset = {1, 0}; 42 my_setsockopt(sock, SOL_SOCKET, SO_LINGER, 43 (void*)&hard_reset, sizeof(hard_reset)); 44 } 45 46 my_socket_close(sock); 47 } 48 49 C_MODE_START 50 51 /* 52 create a pair of connected sockets 53 */ 54 int my_socketpair(ndb_socket_t s[2]); 55 56 C_MODE_END 57 58 #endif 59