WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
NetworkStream.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <cstddef>
8#include <string_view>
9
10namespace wpi::net {
11
13 public:
14 NetworkStream() = default;
15 virtual ~NetworkStream() = default;
16
23
24 virtual size_t send(const char* buffer, size_t len, Error* err) = 0;
25 virtual size_t receive(char* buffer, size_t len, Error* err,
26 int timeout = 0) = 0;
27 virtual void close() = 0;
28
29 virtual std::string_view getPeerIP() const = 0;
30 virtual int getPeerPort() const = 0;
31 virtual void setNoDelay() = 0;
32
33 // returns false on failure
34 virtual bool setBlocking(bool enabled) = 0;
35 virtual int getNativeHandle() const = 0;
36
37 NetworkStream(const NetworkStream&) = delete;
39};
40
41} // namespace wpi::net
virtual int getNativeHandle() const =0
virtual ~NetworkStream()=default
virtual void setNoDelay()=0
virtual size_t send(const char *buffer, size_t len, Error *err)=0
NetworkStream(const NetworkStream &)=delete
virtual void close()=0
virtual std::string_view getPeerIP() const =0
Error
Definition NetworkStream.hpp:17
@ kConnectionReset
Definition NetworkStream.hpp:19
@ kConnectionClosed
Definition NetworkStream.hpp:18
@ kWouldBlock
Definition NetworkStream.hpp:21
@ kConnectionTimedOut
Definition NetworkStream.hpp:20
virtual bool setBlocking(bool enabled)=0
virtual int getPeerPort() const =0
NetworkStream & operator=(const NetworkStream &)=delete
virtual size_t receive(char *buffer, size_t len, Error *err, int timeout=0)=0
Definition Errors.hpp:112
Definition raw_socket_ostream.hpp:9