class Poco::Net::StreamSocketImpl

Overview

This class implements a TCP socket. Moreā€¦

#include <StreamSocketImpl.h>

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

    StreamSocketImpl();
    StreamSocketImpl(IPAddress::Family addressFamily);
    StreamSocketImpl(poco_socket_t sockfd);

    // methods

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

// direct descendants

class WebSocketImpl;

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 a TCP socket.

Construction

StreamSocketImpl()

Creates a StreamSocketImpl.

StreamSocketImpl(IPAddress::Family addressFamily)

Creates a SocketImpl, with the underlying socket initialized for the given address family.

StreamSocketImpl(poco_socket_t sockfd)

Creates a StreamSocketImpl using the given native socket.

Methods

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

Ensures that all data in buffer is sent if the socket is blocking.

In case of a non-blocking socket, sends as many bytes as possible.

Returns the number of bytes sent. The return value may also be negative to denote some special condition.