Poco Library Chinese Programming Reference Guide (5) poco::net::socketaddress

Source: Internet
Author: User

1 enumeration

The maximum address length, which Poco::Net::IPAddress is analogous to the definition in, but refers to the ' struct SOCKADDR_IN6

enum{    MAX_ADDRESS_LENGTH = #if defined(POCO_HAVE_IPv6)        sizeof(struct sockaddr_in6)#else        sizeof(struct sockaddr_in)#endif        /// Maximum length in bytes of a socket address.};
2 constructors

Create a wildcard full 0 IPv4 socket address:

SocketAddress();

Create a socketaddress of IPv4 or IPv6 with poco::net::ipaddress and port numbers:

SocketAddress(const IPAddress& host, Poco::UInt16 port);

Create a socketaddress of IPv4 or IPv6 with std::string and port numbers:

SocketAddress(const std::string& host, Poco::UInt16 port);SocketAddress(const std::string& host, const std::string& port);explicit SocketAddress(const std::string& hostAndPort);

Copy constructor:

SocketAddress(const SocketAddress& addr);

Native Mode construction socketaddress:

SocketAddress(const struct sockaddr* addr, poco_socklen_t length);
3 Common functions

Swap

Get IPAddress, ports, and address types:

IPAddress host() const;Poco::UInt16 port() const;IPAddress::Family family() const;

Gets the address length, address, and address family of the native mode:

poco_socklen_t length() const;  const struct sockaddr* addr() const;int af() const;

Tostring:

std::string toString() const;
4 Overloaded operators
bool operator == (const SocketAddress& addr) const;bool operator != (const SocketAddress& addr) const;
5 protected function
void init(const IPAddress& host, Poco::UInt16 port);void init(const std::string& host, Poco::UInt16 port);Poco::UInt16 resolveService(const std::string& service);

-

From:blog.csdn.net/poechant

Poco Library Chinese Programming Reference Guide (5) poco::net::socketaddress

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.