2016-09-25 17:23:39 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-01 17:32:39 -08:00
|
|
|
/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
|
2016-09-25 17:23:39 -07:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
#ifndef WPIUTIL_WPI_RAW_SOCKET_ISTREAM_H_
|
|
|
|
|
#define WPIUTIL_WPI_RAW_SOCKET_ISTREAM_H_
|
2016-09-25 17:23:39 -07:00
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
#include "wpi/raw_istream.h"
|
2016-09-25 17:23:39 -07:00
|
|
|
|
|
|
|
|
namespace wpi {
|
|
|
|
|
|
2016-09-02 20:53:45 -07:00
|
|
|
class NetworkStream;
|
|
|
|
|
|
2016-09-25 17:23:39 -07:00
|
|
|
class raw_socket_istream : public raw_istream {
|
|
|
|
|
public:
|
2016-09-02 23:36:23 -07:00
|
|
|
explicit raw_socket_istream(NetworkStream& stream, int timeout = 0)
|
2016-09-25 17:23:39 -07:00
|
|
|
: m_stream(stream), m_timeout(timeout) {}
|
2016-09-02 20:53:45 -07:00
|
|
|
|
|
|
|
|
void close() override;
|
2017-10-21 20:31:20 -07:00
|
|
|
size_t in_avail() const override;
|
2016-09-25 17:23:39 -07:00
|
|
|
|
|
|
|
|
private:
|
2017-10-21 20:31:20 -07:00
|
|
|
void read_impl(void* data, size_t len) override;
|
2016-09-02 20:53:45 -07:00
|
|
|
|
2016-09-25 17:23:39 -07:00
|
|
|
NetworkStream& m_stream;
|
|
|
|
|
int m_timeout;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace wpi
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
#endif // WPIUTIL_WPI_RAW_SOCKET_ISTREAM_H_
|