14#ifndef SOCKET_ADDRESS_H
15#define SOCKET_ADDRESS_H
19#include "socket_portable.h"
25class EXPCL_PANDA_NATIVENET Socket_Address {
27 INLINE Socket_Address(
const struct sockaddr &inaddr);
28 INLINE Socket_Address(
const struct sockaddr_in &inaddr);
29 INLINE Socket_Address(
const struct sockaddr_in6 &inaddr);
30 INLINE Socket_Address(
const struct sockaddr_storage &inaddr);
31 INLINE
struct sockaddr &GetAddressInfo() {
return _addr; }
32 INLINE
const struct sockaddr &GetAddressInfo()
const {
return _addr; }
35 INLINE
explicit Socket_Address(
unsigned short port = 0);
36 INLINE Socket_Address(
const Socket_Address &inaddr);
38 INLINE
virtual ~Socket_Address();
42 INLINE
bool set_port(
unsigned short port);
45 bool set_host(
const std::string &hostname,
unsigned short port);
46 bool set_host(
const std::string &hostname);
47 INLINE
bool set_host(uint32_t ip4addr,
unsigned short port);
51 INLINE
unsigned short get_port()
const;
52 std::string
get_ip()
const ;
56 INLINE
bool operator ==(
const Socket_Address &in)
const;
57 INLINE
bool operator !=(
const Socket_Address &in)
const;
58 INLINE
bool operator < (
const Socket_Address &in)
const;
60 INLINE
bool is_any()
const;
68 sockaddr_storage _storage;
sa_family_t get_family() const
Returns AF_INET if this is an IPv4 address, or AF_INET6 if this is an IPv6 address.
bool set_host(const std::string &hostname, unsigned short port)
This function will take a port and string-based TCP address and initialize the address with this info...
bool set_broadcast(unsigned short port)
Set to the broadcast address and a specified port.
void clear()
Set the internal values to a suitable known value.
bool is_mcast_range() const
True if the address is in the multicast range.
bool set_any_IPv6(unsigned short port)
Set to any IPv6 address and a specified port.
std::string get_ip() const
Return the IP address portion in dot notation string.
unsigned long GetIPAddressRaw() const
Returns a raw 32-bit unsigned integer representing the IPv4 address.
bool is_any() const
True if the address is zero.
bool set_any_IP(unsigned short port)
Set to any address and a specified port.
std::string get_ip_port() const
Return the ip address/port in dot notation string.
unsigned short get_port() const
Get the port portion as an integer.
bool set_port(unsigned short port)
Set to a specified port.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.