Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
SocketStream.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include "Stroika/Foundation/Common/Common.h"
#include "Stroika/Foundation/Execution/Synchronized.h"
#include "Stroika/Foundation/IO/Network/ConnectionOrientedStreamSocket.h"
#include "Stroika/Foundation/Streams/InputOutputStream.h"
#include "SocketStream.inl"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 
namespace  Stroika::Foundation::IO::Network
 

Typedefs

using Stroika::Foundation::IO::Network::SocketStream::Ptr = Streams::InputOutputStream::Ptr< byte >
 

Functions

Ptr Stroika::Foundation::IO::Network::SocketStream::New (Execution::InternallySynchronized internallySynchronized, const ConnectionOrientedStreamSocket::Ptr &sd)
 

Typedef Documentation

◆ Ptr

using Stroika::Foundation::IO::Network::SocketStream::Ptr = typedef Streams::InputOutputStream::Ptr<byte>

A SocketStream wraps a a socket as a InputOutputStream - two separate but related streams.

The only real connection is that they share a common socket, and if it is closed, then the whole SocketStream will stop working.

\note   SocketStream adopts its owned ConnectionOrientedStreamSocket, so that a Close () on SocketStream
        will Close that socket as well.

        But SocketStream is an InputOutputStream - so you can close the input and output sides separately.
        If you call close on only one side of the input stream, Shutdown () will be used to shutdown
        just that end of the stream.

        Closing both sides of the stream (calling Close on the InputOutputStream) closes both sides and
        ShutDowns both sides of the socket.
Example Usage
ConnectionOrientedStreamSocket::Ptr connectionSocket = from_somewhere;
SocketStream::Ptr inOut = SocketStream::New (connectionSocket);

Definition at line 46 of file IO/Network/SocketStream.h.

Function Documentation

◆ New()

auto Stroika::Foundation::IO::Network::SocketStream::New ( Execution::InternallySynchronized  internallySynchronized,
const ConnectionOrientedStreamSocket::Ptr sd 
)

To copy a SocketStream, use SocketStream<T>::Ptr

Example Usage
ConnectionOrientedStreamSocket::Ptr connectionSocket = from_somewhere;
SocketStream::Ptr socketStream = SocketStream::New (connectionSocket);
InputStream::Ptr<byte> in = BufferedInputStream::New<byte> (socketStream); // not important, but a good idea, to avoid excessive read/write calls
OutputStream::Ptr<byte> out = BufferedOutputStream::New<byte> (socketStream); // more important so we don't write multiple packets

Definition at line 146 of file IO/Network/SocketStream.cpp.