xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
network_stream.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <iostream>
7 #include "socket.h"
8 
10 namespace xtd {
12  namespace net {
14  namespace sockets {
29  class network_stream : public std::iostream {
30  class socket_streambuf : public std::streambuf {
31  public:
32  socket_streambuf(const xtd::net::sockets::socket& socket, bool owns_socket);
33  ~socket_streambuf();
34 
35  int underflow() override;
36  int overflow(int value) override;
37 
39  bool owns_socket_ = false;
40  char value_ = EOF;
41  };
42 
43  public:
48 
53  network_stream(const xtd::net::sockets::socket& socket, bool owns_socket);
54 
60  virtual bool data_available() const;
61 
66 
67  private:
68  socket_streambuf stream_buf_;
69  };
70  }
71  }
72 }
Implements the Berkeley sockets interface.
Definition: socket.h:63
Provides the underlying stream of data for network access.
Definition: network_stream.h:29
virtual bool data_available() const
Gets a value that indicates whether data is available on the xtd::net::sockets::network_stream to be ...
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
xtd::net::sockets::socket socket() const
Gets the underlying xtd::net::sockets::socket.
network_stream(const xtd::net::sockets::socket &socket)
Creates a new instance of the network_stream class for the specified xtd::net::sockets::socket.
Contains xtd::net::sockets::socket class.