jsocketpp 1.0
A cross-platform C++20 socket library.
Loading...
Searching...
No Matches
common.hpp File Reference

Common platform and utility includes for jsocketpp. More...

Go to the source code of this file.

Namespaces

namespace  jsocketpp
 A C++ socket library providing Java-style networking interfaces.
namespace  jsocketpp::net
 Endianness utilities for network byte order conversion.

Typedefs

typedef int jsocketpp::SOCKET
typedef sockaddr_un jsocketpp::SOCKADDR_UN
using jsocketpp::Port = std::uint16_t
 Type alias representing a TCP or UDP port number (1–65535).

Enumerations

enum class  jsocketpp::ShutdownMode { jsocketpp::Read , jsocketpp::Write , jsocketpp::Both }
 Enum for socket shutdown modes. More...

Functions

int jsocketpp::InitSockets ()
int jsocketpp::CleanupSockets ()
int jsocketpp::GetSocketError ()
int jsocketpp::CloseSocket (SOCKET fd)
const char * jsocketpp::inet_ntop_aux (int af, const void *src, char *dst, socklen_t size)
int jsocketpp::ioctlsocket (const SOCKET fd, const long cmd, u_long *argp)
std::vector< std::string > jsocketpp::getHostAddr ()
 Get all local network interface addresses as strings.
std::string jsocketpp::SocketErrorMessage (int error, bool gaiStrerror=false)
 Returns a human-readable error message for a socket error code.
std::string jsocketpp::SocketErrorMessageWrap (int error, bool gaiStrerror=false)
 Returns a human-readable error message for a socket error code, with exception safety.
bool jsocketpp::isIPv4MappedIPv6 (const sockaddr_in6 *addr6)
 Checks if a given sockaddr_in6 represents an IPv4-mapped IPv6 address.
sockaddr_in jsocketpp::convertIPv4MappedIPv6ToIPv4 (const sockaddr_in6 &addr6)
 Converts an IPv4-mapped IPv6 address to a pure IPv4 sockaddr_in.
uint16_t jsocketpp::net::toNetwork (const uint16_t val)
 Converts a 16-bit unsigned integer from host to network byte order.
uint32_t jsocketpp::net::toNetwork (const uint32_t val)
 Converts a 32-bit unsigned integer from host to network byte order.
uint16_t jsocketpp::net::fromNetwork (const uint16_t val)
 Converts a 16-bit unsigned integer from network to host byte order.
uint32_t jsocketpp::net::fromNetwork (const uint32_t val)
 Converts a 32-bit unsigned integer from network to host byte order.

Variables

constexpr SOCKET jsocketpp::INVALID_SOCKET = -1
constexpr SOCKET jsocketpp::SOCKET_ERROR = -1
constexpr std::size_t jsocketpp::DefaultBufferSize = 4096
 Default internal buffer size (in bytes) for TCP socket read operations.

Detailed Description

Common platform and utility includes for jsocketpp.