4
* Copyright 2011 Mark Wright
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
21
* @brief ZeroMQ Echo Server Module Definitions
26
#include <scalestack/zeromq/connection_service.h>
27
#include <scalestack/zeromq/echo/server/socket_service.h>
28
#include <scalestack/zeromq/echo/server/socket_t.h>
31
using namespace scalestack;
33
static void options(kernel::module& module)
35
module.add_option("random_buffer_size", _("Size of random buffer to echo."),
39
static void start(kernel::module& module)
41
auto_ptr<zeromq::socket_service> socket_service(
42
new zeromq::echo::server::socket_service(module));
43
auto_ptr<zeromq::connection_service> connection_service(
44
new zeromq::connection_service(module, socket_service));
46
// the connection service handles both bind and/or connect. As zeromq
47
// can do multiple binds and/or multiple connects on the same socket with
48
// some zeromq socket types.
49
// Hence is seems to be best to place the listener service / address stuff into the
50
// the zeromq::connection_service, and not have a listener_service.
52
connection_service->add_listeners();
53
module.get_core().add_service("zeromq::echo::server", connection_service.get());
56
static void stop(kernel::module& module)
58
delete module.get_core().remove_service("zeromq::echo::server");
61
SCALESTACK_KERNEL_MODULE(options, start, stop, NULL, NULL);