/usr/include/dlib/sockstreambuf/sockstreambuf_abstract.h is in libdlib-dev 18.18-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | // Copyright (C) 2003 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_SOCKSTREAMBUF_ABSTRACT_
#ifdef DLIB_SOCKSTREAMBUF_ABSTRACT_
#include <iosfwd>
#include <streambuf>
#include "../sockets/sockets_kernel_abstract.h"
namespace dlib
{
// ----------------------------------------------------------------------------------------
class sockstreambuf : public std::streambuf
{
/*!
WHAT THIS OBJECT REPRESENTS
This object represents a stream buffer capable of writing to and
reading from TCP connections.
NOTE:
For a sockstreambuf EOF is when the connection has closed or otherwise
returned some kind of error.
Also note that any data written to the streambuf may be buffered
internally. So if you need to ensure that data is actually sent then you
should flush the stream.
A read operation is guaranteed to block until the number of bytes
requested has arrived on the connection. It will never keep blocking
once enough data has arrived.
THREADING
Generally speaking, this object has the same kind of threading
restrictions as a connection object. those being:
- Do not try to write to a sockstreambuf from more than one thread.
- Do not try to read from a sockstreambuf from more than one thread.
- You may call shutdown() on the connection object and this will
cause any reading or writing calls to end. To the sockstreambuf it
will appear the same as hitting EOF. (note that EOF for a sockstreambuf
means that the connection has closed)
- It is safe to read from and write to the sockstreambuf at the same time
from different threads so long as flushes_output_on_read()==false.
- It is not safe to try to putback a char and read from the stream from
different threads
!*/
public:
sockstreambuf (
connection* con
);
/*!
requires
- con == a valid connection object
ensures
- *this will read from and write to con
- #flushes_output_on_read() == false
throws
- std::bad_alloc
!*/
sockstreambuf (
const scoped_ptr<connection>& con
);
/*!
requires
- con == a valid connection object
ensures
- *this will read from and write to con
- #flushes_output_on_read() == false
throws
- std::bad_alloc
!*/
~sockstreambuf (
);
/*!
requires
- get_connection() object has not been deleted
ensures
- sockstream buffer is destructed but the connection object will
NOT be closed.
- Any buffered data is flushed to the connection.
!*/
connection* get_connection (
);
/*!
ensures
- returns a pointer to the connection object which this buffer
reads from and writes to
!*/
void flush_output_on_read (
);
/*!
ensures
- #flushes_output_on_read() == true
!*/
bool flushes_output_on_read (
) const;
/*!
ensures
- This function returns true if this object will flush its output buffer
to the network socket before performing any network read.
- if (flushes_output_on_read() == true)
- It is not safe to make concurrent read and write calls to this object.
!*/
void do_not_flush_output_on_read (
);
/*!
ensures
- #flushes_output_on_read() == false
!*/
};
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_SOCKSTREAMBUF_ABSTRACT_
|