MeVisLab Toolbox Reference
Socket.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 
4 #pragma once
5 
6 #include <asio/ErrorCodes.h>
7 
8 #include <ThirdPartyWarningsDisable.h>
9 #include <functional>
10 #include <cstddef>
11 #include <ThirdPartyWarningsRestore.h>
12 
13 
14 namespace asio {
15 
22  class Socket
23  {
24  public:
25 
26  using CompletionHandler = std::function<void(const ErrorCode&, const std::size_t /* number of bytes transferred */)>;
27 
28  virtual ~Socket() = default;
29 
30  virtual bool is_valid() const = 0;
31 
32  virtual void async_read(void* buffer, const std::size_t buffer_size, const CompletionHandler& handler) = 0;
33 
34  virtual void async_write(const void* buffer, const std::size_t buffer_size, const CompletionHandler& handler) = 0;
35 
36  virtual void close() = 0;
37  };
38 
39 }
Abstract base class for an asynchronous channel supporting read and write of binary data.
Definition: Socket.h:23
virtual ~Socket()=default
virtual void close()=0
std::function< void(const ErrorCode &, const std::size_t)> CompletionHandler
Definition: Socket.h:26
virtual bool is_valid() const =0
virtual void async_read(void *buffer, const std::size_t buffer_size, const CompletionHandler &handler)=0
virtual void async_write(const void *buffer, const std::size_t buffer_size, const CompletionHandler &handler)=0
boost::system::error_code ErrorCode
Definition: ErrorCodes.h:13