1//
2// EchoServer.h
3//
4// Definition of the EchoServer class.
5//
6// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
7// and Contributors.
8//
9// SPDX-License-Identifier: BSL-1.0
10//
11
12
13#ifndef EchoServer_INCLUDED
14#define EchoServer_INCLUDED
15
16
17#include "Poco/Net/Net.h"
18#include "Poco/Net/ServerSocket.h"
19#include "Poco/Thread.h"
20#include "Poco/Event.h"
21
22
23class EchoServer: public Poco::Runnable
24 /// A simple sequential echo server.
25{
26public:
27 EchoServer();
28 /// Creates the EchoServer.
29
30 EchoServer(const Poco::Net::SocketAddress& address);
31 /// Creates the EchoServer using the given address.
32
33 ~EchoServer();
34 /// Destroys the EchoServer.
35
36 Poco::UInt16 port() const;
37 /// Returns the port the echo server is
38 /// listening on.
39
40 void run();
41 /// Does the work.
42
43private:
44 Poco::Net::ServerSocket _socket;
45 Poco::Thread _thread;
46 Poco::Event _ready;
47 bool _stop;
48};
49
50
51#endif // EchoServer_INCLUDED
52