C + + Poco library Chinese Programming Reference Guide (7) poco::net::D atagramsocket

Source: Internet
Author: User

1 constructors

Create a disconnected IPv4 datagram Socket:

Datagramsocket ();

Creates a datagram Socket that specifies the IP type (IPV4 or IPV6):

Explicit Datagramsocket (ipaddress::family Family);

Create a datagram Socket with a specified socketaddress

Datagramsocket (const socketaddress& address, bool 

reuseaddress = false);   
       
Datagramsocket (const socket& Socket);   
    Creates the Datagramsocket with the SocketImpl   
    ///from another socket. The SocketImpl must   
    is///a datagramsocketimpl, otherwise an invalidargumentexception   
    ///would be thrown.

2 Overloaded operators

datagramsocket& operator = (const socket& Socket);   
    Assignment operator.   
    ///releases the socket ' s SocketImpl and///attaches the SocketImpl from the other   
    socket and   
    /// Ements the reference count of the SocketImpl.

3 Common operations

3.1 Connections and bindings

void Connect (const socketaddress& address);

void bind (const socketaddress& address, BOOL reuseaddress = false);

3.2 Send and receive data without regard to client

int sendbytes (const void* buffer, int length, int flags = 0);

int receivebytes (void* buffer, int length, int flags = 0);

3.3 Manipulation data and obtaining client's socketaddress

int SendTo (const void* buffer, int length, const socketaddress& address, int flags = 0);

int ReceiveFrom (void* buffer, int length, socketaddress& address, int flags = 0);

3.4 Radio and transceiver

void Setbroadcast (bool flag);

BOOL Getbroadcast () const;

4 protected function

Datagramsocket (socketimpl* Pimpl);

Reprinted please the famous 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.