Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
IO/Network/SocketStream.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_IO_Network_SocketStream_h_
5#define _Stroika_Foundation_IO_Network_SocketStream_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Common/Common.h"
11#include "Stroika/Foundation/IO/Network/ConnectionOrientedStreamSocket.h"
13
14/**
15 * \file
16 */
17
18namespace Stroika::Foundation::IO::Network::SocketStream {
19
20 /**
21 */
22 using IRep = Streams::InputOutputStream::IRep<byte>;
23
24 /**
25 * A SocketStream wraps a a socket as a InputOutputStream - two separate but related streams.
26 *
27 * The only real connection is that they share a common socket, and if it is closed,
28 * then the whole SocketStream will stop working.
29 *
30 * \note SocketStream adopts its owned ConnectionOrientedStreamSocket, so that a Close () on SocketStream
31 * will Close that socket as well.
32 *
33 * But SocketStream is an InputOutputStream - so you can close the input and output sides separately.
34 * If you call close on only one side of the input stream, Shutdown () will be used to shutdown
35 * just that end of the stream.
36 *
37 * Closing both sides of the stream (calling Close on the InputOutputStream) closes both sides and
38 * ShutDowns both sides of the socket.
39 *
40 * \par Example Usage
41 * \code
42 * ConnectionOrientedStreamSocket::Ptr connectionSocket = from_somewhere;
43 * SocketStream::Ptr inOut = SocketStream::New (connectionSocket);
44 * \endcode
45 */
47
48 /**
49 * To copy a SocketStream, use SocketStream<T>::Ptr
50 *
51 * \par Example Usage
52 * \code
53 * ConnectionOrientedStreamSocket::Ptr connectionSocket = from_somewhere;
54 * SocketStream::Ptr socketStream = SocketStream::New (connectionSocket);
55 * InputStream::Ptr<byte> in = BufferedInputStream::New<byte> (socketStream); // not important, but a good idea, to avoid excessive read/write calls
56 * OutputStream::Ptr<byte> out = BufferedOutputStream::New<byte> (socketStream); // more important so we don't write multiple packets
57 * \endcode
58 */
61
62}
63
64/*
65 ********************************************************************************
66 ***************************** Implementation Details ***************************
67 ********************************************************************************
68 */
69#include "SocketStream.inl"
70
71#endif /*_Stroika_Foundation_IO_Network_SocketStream_h_*/
InputOutputStream is single stream object that acts much as a InputStream::Ptr and an OutputStream::P...