Browse Source

Added pton4() and pton6() static functions to Jupiter::Socket.

release/0.19
JustinAJ 10 years ago
parent
commit
21326918e9
  1. 16
      Jupiter/Socket.cpp
  2. 17
      Jupiter/Socket.h
  3. BIN
      Release/Jupiter.lib

16
Jupiter/Socket.cpp

@ -300,6 +300,22 @@ char *Jupiter::Socket::resolveHostname(const char *hostname, unsigned int result
return Jupiter::Socket::resolveHostname(info, result);
}
uint32_t Jupiter::Socket::pton4(const char *str)
{
in_addr r;
if (inet_pton(AF_INET, str, &r) <= 0)
return 0;
return *reinterpret_cast<uint32_t *>(&r);
}
in_addr6 Jupiter::Socket::pton6(const char *str)
{
in_addr6 r;
if (inet_pton(AF_INET6, str, &r) <= 0)
memset(&r, 0, sizeof(in_addr6));
return r;
}
Jupiter::Socket *Jupiter::Socket::acceptConnection()
{
SOCKET tSock = accept(Socket::data_->rawSock, 0, 0);

17
Jupiter/Socket.h

@ -28,6 +28,7 @@
#include "Readable_String.h"
struct addrinfo;
struct in_addr6;
namespace Jupiter
{
@ -163,6 +164,22 @@ namespace Jupiter
*/
static char *resolveHostname(const char *hostname, unsigned int result);
/**
* @brief Reinterprets an IPv4 address as a 32-bit integer in network byte order.
*
* @param str String representation of an IPv4 address.
* @return IPv4 address in network byte order.
*/
static uint32_t pton4(const char *str);
/**
* @brief Reinterprets an IPv6 address as a 128-bit integer in network byte order.
*
* @param str String representation of an IPv6 address.
* @return IPv6 address in network byte order.
*/
static in_addr6 pton6(const char *str);
/**
* @brief Interface to provide simple connection establishing.
* Note: When using this method, the hostname and port are NOT stored; thus getHost(), getHostname(),

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save