C + + Poco library Chinese Programming Reference Guide (5) poco::net::socketaddress

Source: Internet
Author: User
Tags bool socket tostring

1 enumeration

The maximum address length, which is analogous to the definition in poco::net::ipaddress, but it refers to ' 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 the a socket address.   
};

2 constructors

Create a wildcard full 0 IPv4 socket address:

SocketAddress ();

Create IPV4 or IPv6 socketaddress with poco::net::ipaddress and port numbers:

SocketAddress (const ipaddress& host, poco::uint16 Port);

Create IPV4 or IPv6 socketaddress 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 form structure socketaddress:

socketaddress (const struct sockaddr* addr, poco_socklen_t length);

3 Common functions

Swap

void swap (socketaddress& addr);

Get IPAddress, port, 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 way:

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);

Reprint please indicate the CSDN blog from Liuda: blog.csdn.net/poechant

View a full set of articles: Http://www.bianceng.cn/Programming/cplus/201301/35022.htm

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.