WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
NetworkStream.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2015. 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 TCPSOCKETS_NETWORKSTREAM_H_
9 #define TCPSOCKETS_NETWORKSTREAM_H_
10 
11 #include <cstddef>
12 
13 #include "llvm/StringRef.h"
14 
16  public:
17  NetworkStream() = default;
18  virtual ~NetworkStream() = default;
19 
20  enum Error {
21  kConnectionClosed = 0,
22  kConnectionReset = -1,
23  kConnectionTimedOut = -2
24  };
25 
26  virtual std::size_t send(const char* buffer, std::size_t len, Error* err) = 0;
27  virtual std::size_t receive(char* buffer, std::size_t len, Error* err,
28  int timeout = 0) = 0;
29  virtual void close() = 0;
30 
31  virtual llvm::StringRef getPeerIP() const = 0;
32  virtual int getPeerPort() const = 0;
33  virtual void setNoDelay() = 0;
34 
35  NetworkStream(const NetworkStream&) = delete;
36  NetworkStream& operator=(const NetworkStream&) = delete;
37 };
38 
39 #endif // TCPSOCKETS_NETWORKSTREAM_H_
Definition: NetworkStream.h:15
Error object represents a library error.
Definition: Error.h:28
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:39