class Poco::Net::DatagramSocketImpl

Overview

This class implements an UDP socket. Moreā€¦

#include <DatagramSocketImpl.h>

class DatagramSocketImpl: public Poco::Net::SocketImpl
{
public:
    // construction

    DatagramSocketImpl();
    DatagramSocketImpl(IPAddress::Family family);
    DatagramSocketImpl(poco_socket_t sockfd);

protected:
    // methods

    virtual
    void
    init(int af);
};

Inherited Members

public:
    // enums

    enum SelectMode;

    // methods

    void
    duplicate() const;

    void
    release() const;

    int
    referenceCount() const;

    virtual
    SocketImpl*
    acceptConnection(SocketAddress& clientAddr);

    virtual
    void
    connect(const SocketAddress& address);

    virtual
    void
    connect(
        const SocketAddress& address,
        const Poco::Timespan& timeout
        );

    virtual
    void
    connectNB(const SocketAddress& address);

    virtual
    void
    bind(
        const SocketAddress& address,
        bool reuseAddress = false
        );

    virtual
    void
    bind6(
        const SocketAddress& address,
        bool reuseAddress = false,
        bool ipV6Only = false
        );

    virtual
    void
    listen(int backlog = 64);

    virtual
    void
    close();

    virtual
    void
    shutdownReceive();

    virtual
    void
    shutdownSend();

    virtual
    void
    shutdown();

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

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

    virtual
    int
    sendTo(
        const void* buffer,
        int length,
        const SocketAddress& address,
        int flags = 0
        );

    virtual
    int
    receiveFrom(
        void* buffer,
        int length,
        SocketAddress& address,
        int flags = 0
        );

    virtual
    void
    sendUrgent(unsigned char data);

    virtual
    int
    available();

    virtual
    bool
    poll(
        const Poco::Timespan& timeout,
        int mode
        );

    virtual
    void
    setSendBufferSize(int size);

    virtual
    int
    getSendBufferSize();

    virtual
    void
    setReceiveBufferSize(int size);

    virtual
    int
    getReceiveBufferSize();

    virtual
    void
    setSendTimeout(const Poco::Timespan& timeout);

    virtual
    Poco::Timespan
    getSendTimeout();

    virtual
    void
    setReceiveTimeout(const Poco::Timespan& timeout);

    virtual
    Poco::Timespan
    getReceiveTimeout();

    virtual
    SocketAddress
    address();

    virtual
    SocketAddress
    peerAddress();

    void
    setOption(
        int level,
        int option,
        int value
        );

    void
    setOption(
        int level,
        int option,
        unsigned value
        );

    void
    setOption(
        int level,
        int option,
        unsigned char value
        );

    void
    setOption(
        int level,
        int option,
        const Poco::Timespan& value
        );

    void
    setOption(
        int level,
        int option,
        const IPAddress& value
        );

    virtual
    void
    setRawOption(
        int level,
        int option,
        const void* value,
        poco_socklen_t length
        );

    void
    getOption(
        int level,
        int option,
        int& value
        );

    void
    getOption(
        int level,
        int option,
        unsigned& value
        );

    void
    getOption(
        int level,
        int option,
        unsigned char& value
        );

    void
    getOption(
        int level,
        int option,
        Poco::Timespan& value
        );

    void
    getOption(
        int level,
        int option,
        IPAddress& value
        );

    virtual
    void
    getRawOption(
        int level,
        int option,
        void* value,
        poco_socklen_t& length
        );

    void
    setLinger(
        bool on,
        int seconds
        );

    void
    getLinger(
        bool& on,
        int& seconds
        );

    void
    setNoDelay(bool flag);

    bool
    getNoDelay();

    void
    setKeepAlive(bool flag);

    bool
    getKeepAlive();

    void
    setReuseAddress(bool flag);

    bool
    getReuseAddress();

    void
    setReusePort(bool flag);

    bool
    getReusePort();

    void
    setOOBInline(bool flag);

    bool
    getOOBInline();

    void
    setBroadcast(bool flag);

    bool
    getBroadcast();

    virtual
    void
    setBlocking(bool flag);

    virtual
    bool
    getBlocking() const;

    virtual
    bool
    secure() const;

    int
    socketError();

    poco_socket_t
    sockfd() const;

    void
    ioctl(
        poco_ioctl_request_t request,
        int& arg
        );

    void
    ioctl(
        poco_ioctl_request_t request,
        void* arg
        );

    bool
    initialized() const;

protected:
    // methods

    virtual
    void
    init(int af);

    void
    initSocket(
        int af,
        int type,
        int proto = 0
        );

    void
    reset(poco_socket_t fd = POCO_INVALID_SOCKET);

    static
    int
    lastError();

    static
    void
    error();

    static
    void
    error(const std::string& arg);

    static
    void
    error(int code);

    static
    void
    error(
        int code,
        const std::string& arg
        );

Detailed Documentation

This class implements an UDP socket.

Construction

DatagramSocketImpl()

Creates an unconnected, unbound datagram socket.

DatagramSocketImpl(IPAddress::Family family)

Creates an unconnected datagram socket.

The socket will be created for the given address family.

DatagramSocketImpl(poco_socket_t sockfd)

Creates a StreamSocketImpl using the given native socket.

Methods

virtual
void
init(int af)

Creates the underlying native socket.

Subclasses must implement this method so that it calls initSocket() with the appropriate arguments.

The default implementation creates a stream socket.