WPILibC++
2020.3.2
NetworkStream.h
1
/*----------------------------------------------------------------------------*/
2
/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
3
/* Open Source Software - may be modified and shared by FRC teams. The code */
4
/* must be accompanied by the FIRST BSD license file in the root directory of */
5
/* the project. */
6
/*----------------------------------------------------------------------------*/
7
8
#ifndef WPIUTIL_WPI_NETWORKSTREAM_H_
9
#define WPIUTIL_WPI_NETWORKSTREAM_H_
10
11
#include <cstddef>
12
13
#include "wpi/StringRef.h"
14
15
namespace
wpi
{
16
17
class
NetworkStream
{
18
public
:
19
NetworkStream
() =
default
;
20
virtual
~
NetworkStream
() =
default
;
21
22
enum
Error {
23
kConnectionClosed = 0,
24
kConnectionReset = -1,
25
kConnectionTimedOut = -2,
26
kWouldBlock = -3
27
};
28
29
virtual
size_t
send(
const
char
* buffer,
size_t
len, Error* err) = 0;
30
virtual
size_t
receive(
char
* buffer,
size_t
len, Error* err,
31
int
timeout = 0) = 0;
32
virtual
void
close() = 0;
33
34
virtual
StringRef
getPeerIP()
const
= 0;
35
virtual
int
getPeerPort()
const
= 0;
36
virtual
void
setNoDelay() = 0;
37
38
// returns false on failure
39
virtual
bool
setBlocking(
bool
enabled) = 0;
40
virtual
int
getNativeHandle()
const
= 0;
41
42
NetworkStream
(
const
NetworkStream
&) =
delete
;
43
NetworkStream
& operator=(
const
NetworkStream
&) =
delete
;
44
};
45
46
}
// namespace wpi
47
48
#endif // WPIUTIL_WPI_NETWORKSTREAM_H_
wpi
WPILib C++ utilities (wpiutil) namespace.
Definition:
EventLoopRunner.h:17
wpi::NetworkStream
Definition:
NetworkStream.h:17
wpi::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:49
wpiutil
src
main
native
include
wpi
NetworkStream.h
Generated on Fri Feb 21 2020 08:50:37 for WPILibC++ by
1.8.16