Warning, file /sdk/dferry/transport/ipresolver.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002    Copyright (C) 2023 Andreas Hartmetz <ahartmetz@gmail.com>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LGPL.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 
0019    Alternatively, this file is available under the Mozilla Public License
0020    Version 1.1.  You may obtain a copy of the License at
0021    http://www.mozilla.org/MPL/
0022 */
0023 
0024 #ifndef IPRESOLVER_H
0025 #define IPRESOLVER_H
0026 
0027 // For platforms with a POSIX-like API but no getaddrinfo(), comment this out
0028 #define USE_GETADDRINFO
0029 
0030 #ifdef __unix__
0031 #ifdef USE_GETADDRINFO
0032 #include <netdb.h>
0033 #else
0034 #include <arpa/inet.h>
0035 #endif
0036 #endif
0037 
0038 #ifdef _WIN32
0039 #include <ws2tcpip.h>
0040 #endif
0041 
0042 class ConnectAddress;
0043 
0044 class IpResolver
0045 {
0046 public:
0047     IpResolver(const ConnectAddress& ca);
0048     ~IpResolver();
0049 
0050     bool resultValid() const;
0051     const struct sockaddr* resolved() const;
0052     socklen_t resolvedLength() const;
0053 
0054 private:
0055 #ifdef USE_GETADDRINFO
0056     struct addrinfo* m_resolved = nullptr;
0057 #else
0058     struct sockaddr_in m_resolved;
0059 #endif
0060     bool m_resultValid;
0061 };
0062 
0063 #endif // IPRESOLVER_H