MeVisLab Toolbox Reference
TcpAcceptor.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/System.h>
7#include <asio/Context.h>
8#include <asio/TcpSocket.h>
9
10#include <FMEThirdPartyWarningsDisable.h>
11#include <boost/asio/ip/tcp.hpp>
12#include <string>
13#include <utility>
14#include <FMEThirdPartyWarningsRestore.h>
15
16
17namespace asio {
18
40 {
41 public:
42
43 TcpAcceptor(std::shared_ptr<Context> context, const std::string& address, const unsigned short port);
44
45 template<typename AcceptHandler>
47 {
48 this->acceptor.async_accept(candidate.socket, std::forward<AcceptHandler>(handler));
49 }
50
51 unsigned short port() const;
52
53 void cancel();
54
55 void close();
56
57 private:
58
59 std::shared_ptr<Context> context;
60
61 boost::asio::ip::tcp::acceptor acceptor;
62 };
63
64}
#define ASYNCHRONOUSIO_EXPORT
Definition System.h:10
A TCP acceptor listening on a given port and interface address.
Definition TcpAcceptor.h:40
TcpAcceptor(std::shared_ptr< Context > context, const std::string &address, const unsigned short port)
unsigned short port() const
void async_accept(TcpSocket &candidate, AcceptHandler &&handler)
Definition TcpAcceptor.h:46
A TCP socket class implementing the asio::Socket interface.
Definition TcpSocket.h:39
Target mlrange_cast(Source arg)
Generic version of checked ML casts.