Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SocketStream.hpp - github.com/neutrinolabs/ulalaca-xrdp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b94a693832b5a27bd72cc0d8f3b78795c6076ac9 (plain)
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
//
// Created by cheesekun on 2/28/22.
//

#ifndef ULALACA_SOCKETSTREAM_HPP
#define ULALACA_SOCKETSTREAM_HPP

#include <streambuf>

#include "UnixSocket.hpp"

class InputSocketStream: public std::basic_streambuf<uint8_t, std::char_traits<uint8_t>> {
public:
    explicit InputSocketStream(UnixSocketBase &socketLike);

protected:
    static const size_t MAX_BUFFER_SIZE = 8192;
    
    int underflow() override;
    
    uint8_t _buffer[MAX_BUFFER_SIZE];
    UnixSocketBase &_socket;
};

class OutputSocketStream: public std::streambuf {
public:
    explicit OutputSocketStream(UnixSocketBase &socketLike);
    
    void flush();
protected:
    static const size_t MAX_BUFFER_SIZE = 8192;
    
    int overflow(int character) override;
    
    char _buffer[MAX_BUFFER_SIZE];
    UnixSocketBase &_socket;
};


#endif //ULALACA_SOCKETSTREAM_HPP