chromium/third_party/webrtc/rtc_base/socket.h

/*
 *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef RTC_BASE_SOCKET_H_
#define RTC_BASE_SOCKET_H_

#include <errno.h>

#include "absl/types/optional.h"
#include "rtc_base/checks.h"

#if defined(WEBRTC_POSIX)
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#define SOCKET_EACCES
#endif

#if defined(WEBRTC_WIN)
#include "rtc_base/win32.h"
#endif

#include "api/units/timestamp.h"
#include "rtc_base/buffer.h"
#include "rtc_base/network/ecn_marking.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/system/rtc_export.h"
#include "rtc_base/third_party/sigslot/sigslot.h"

// Rather than converting errors into a private namespace,
// Reuse the POSIX socket api errors. Note this depends on
// Win32 compatibility.

#if defined(WEBRTC_WIN)
#undef EWOULDBLOCK  // Remove errno.h's definition for each macro below.
#define EWOULDBLOCK
#undef EINPROGRESS
#define EINPROGRESS
#undef EALREADY
#define EALREADY
#undef EMSGSIZE
#define EMSGSIZE
#undef EADDRINUSE
#define EADDRINUSE
#undef EADDRNOTAVAIL
#define EADDRNOTAVAIL
#undef ENETDOWN
#define ENETDOWN
#undef ECONNABORTED
#define ECONNABORTED
#undef ENOBUFS
#define ENOBUFS
#undef EISCONN
#define EISCONN
#undef ENOTCONN
#define ENOTCONN
#undef ECONNREFUSED
#define ECONNREFUSED
#undef EHOSTUNREACH
#define EHOSTUNREACH
#undef ENETUNREACH
#define ENETUNREACH
#define SOCKET_EACCES
#endif  // WEBRTC_WIN

#if defined(WEBRTC_POSIX)
#define INVALID_SOCKET
#define SOCKET_ERROR
#define closesocket(s)
#endif  // WEBRTC_POSIX

namespace rtc {

inline bool IsBlockingError(int e) {}

// General interface for the socket implementations of various networks.  The
// methods match those of normal UNIX sockets very closely.
class RTC_EXPORT Socket {};

}  // namespace rtc

#endif  // RTC_BASE_SOCKET_H_