WPILibC++
2025.0.0-alpha-1-24-g6478ba6
NetworkStream.h
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
#ifndef WPINET_NETWORKSTREAM_H_
6
#define WPINET_NETWORKSTREAM_H_
7
8
#include <cstddef>
9
#include <string_view>
10
11
namespace
wpi
{
12
13
class
NetworkStream
{
14
public
:
15
NetworkStream
() =
default
;
16
virtual
~NetworkStream
() =
default
;
17
18
enum
Error
{
19
kConnectionClosed
= 0,
20
kConnectionReset
= -1,
21
kConnectionTimedOut
= -2,
22
kWouldBlock
= -3
23
};
24
25
virtual
size_t
send
(
const
char
* buffer,
size_t
len,
Error
* err) = 0;
26
virtual
size_t
receive
(
char
* buffer,
size_t
len,
Error
* err,
27
int
timeout = 0) = 0;
28
virtual
void
close
() = 0;
29
30
virtual
std::string_view
getPeerIP
()
const
= 0;
31
virtual
int
getPeerPort
()
const
= 0;
32
virtual
void
setNoDelay
() = 0;
33
34
// returns false on failure
35
virtual
bool
setBlocking
(
bool
enabled) = 0;
36
virtual
int
getNativeHandle
()
const
= 0;
37
38
NetworkStream
(
const
NetworkStream
&) =
delete
;
39
NetworkStream
&
operator=
(
const
NetworkStream
&) =
delete
;
40
};
41
42
}
// namespace wpi
43
44
#endif
// WPINET_NETWORKSTREAM_H_
wpi::NetworkStream
Definition:
NetworkStream.h:13
wpi::NetworkStream::getNativeHandle
virtual int getNativeHandle() const =0
wpi::NetworkStream::close
virtual void close()=0
wpi::NetworkStream::setNoDelay
virtual void setNoDelay()=0
wpi::NetworkStream::setBlocking
virtual bool setBlocking(bool enabled)=0
wpi::NetworkStream::getPeerIP
virtual std::string_view getPeerIP() const =0
wpi::NetworkStream::NetworkStream
NetworkStream(const NetworkStream &)=delete
wpi::NetworkStream::operator=
NetworkStream & operator=(const NetworkStream &)=delete
wpi::NetworkStream::NetworkStream
NetworkStream()=default
wpi::NetworkStream::send
virtual size_t send(const char *buffer, size_t len, Error *err)=0
wpi::NetworkStream::Error
Error
Definition:
NetworkStream.h:18
wpi::NetworkStream::kConnectionTimedOut
@ kConnectionTimedOut
Definition:
NetworkStream.h:21
wpi::NetworkStream::kWouldBlock
@ kWouldBlock
Definition:
NetworkStream.h:22
wpi::NetworkStream::kConnectionReset
@ kConnectionReset
Definition:
NetworkStream.h:20
wpi::NetworkStream::kConnectionClosed
@ kConnectionClosed
Definition:
NetworkStream.h:19
wpi::NetworkStream::~NetworkStream
virtual ~NetworkStream()=default
wpi::NetworkStream::receive
virtual size_t receive(char *buffer, size_t len, Error *err, int timeout=0)=0
wpi::NetworkStream::getPeerPort
virtual int getPeerPort() const =0
wpi
Definition:
ntcore_cpp.h:26
string_view
basic_string_view< char > string_view
Definition:
base.h:601
wpinet
NetworkStream.h
Generated on Sun Jul 7 2024 13:45:43 for WPILibC++ by
1.9.4