class Poco::Net::SocketStream

Overview

An bidirectional stream for reading from and writing to a socket. More…

#include <SocketStream.h>

class SocketStream:
    public Poco::Net::SocketIOS,
    public iostream
{
public:
    // construction

    SocketStream(const Socket& socket);
};

Inherited Members

public:
    // methods

    SocketStreamBuf*
    rdbuf();

    void
    close();

    StreamSocket
    socket() const;

protected:
    // fields

    SocketStreamBuf _buf;

Detailed Documentation

An bidirectional stream for reading from and writing to a socket.

When using formatted input from a SocketStream, always ensure that a receive timeout is set for the socket. Otherwise your program might unexpectedly hang.

However, using formatted input from a SocketStream is not recommended, due to the read-ahead behavior of istream with formatted reads.

Construction

SocketStream(const Socket& socket)

Creates the SocketStream with the given socket.

The socket’s SocketImpl must be a StreamSocketImpl, otherwise an InvalidArgumentException is thrown.