1ZHTTP_SERVER(3)                   CZMQ Manual                  ZHTTP_SERVER(3)
2
3
4

NAME

6       zhttp_server - Class for no title found
7

SYNOPSIS

9       //  This is a draft class, and may change without notice. It is disabled in
10       //  stable builds by default. If you use this in applications, please ask
11       //  for it to be pushed to stable state. Use --enable-drafts to enable.
12       #ifdef CZMQ_BUILD_DRAFT_API
13       //  *** Draft method, for development use, may change without warning ***
14       //  Create a new http server
15       CZMQ_EXPORT zhttp_server_t *
16           zhttp_server_new (zhttp_server_options_t *options);
17
18       //  *** Draft method, for development use, may change without warning ***
19       //  Destroy an http server
20       CZMQ_EXPORT void
21           zhttp_server_destroy (zhttp_server_t **self_p);
22
23       //  *** Draft method, for development use, may change without warning ***
24       //  Return the port the server is listening on.
25       CZMQ_EXPORT int
26           zhttp_server_port (zhttp_server_t *self);
27
28       //  *** Draft method, for development use, may change without warning ***
29       //  Self test of this class.
30       CZMQ_EXPORT void
31           zhttp_server_test (bool verbose);
32
33       #endif // CZMQ_BUILD_DRAFT_API
34       Please add '@interface' section in './../src/zhttp_server.c'.
35

DESCRIPTION

37       zhttp_server -
38
39       Please add @discuss section in ./../src/zhttp_server.c.
40

EXAMPLE

42       From zhttp_server_test method.
43
44           int port = 40000 + (randof (10000));
45           zhttp_server_options_t *options = zhttp_server_options_new ();
46           zhttp_server_options_set_port (options, port);
47
48           zhttp_server_t *server = zhttp_server_new (options);
49           assert (server);
50           zsock_t *worker = zsock_new_dealer (zhttp_server_options_backend_address (options));
51           zhttp_request_t *request = zhttp_request_new ();
52           void *connection = zhttp_request_recv (request, worker);
53           assert (connection);
54
55           assert (streq (zhttp_request_method (request), "POST"));
56           assert (streq (zhttp_request_url (request), "/"));
57           assert (streq (zhttp_request_content (request), "Hello!"));
58
59           zhttp_response_t *response = zhttp_response_new ();
60           zhttp_response_set_content_const (response, "Welcome!");
61           zhttp_response_set_status_code (response, 200);
62           rc = zhttp_response_send (response, worker, &connection);
63           assert (rc == 0);
64           zhttp_request_destroy (&request);
65           zhttp_response_destroy (&response);
66           zsock_destroy (&worker);
67           zhttp_server_destroy (&server);
68           zhttp_server_options_destroy (&options);
69
70

AUTHORS

72       The czmq manual was written by the authors in the AUTHORS file.
73

RESOURCES

75       Main web site:
76
77       Report bugs to the email <zeromq-dev@lists.zeromq.org[1]>
78
80       Copyright (c) the Contributors as noted in the AUTHORS file. This file
81       is part of CZMQ, the high-level C binding for 0MQ:
82       http://czmq.zeromq.org. This Source Code Form is subject to the terms
83       of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
84       distributed with this file, You can obtain one at
85       http://mozilla.org/MPL/2.0/. LICENSE included with the czmq
86       distribution.
87

NOTES

89        1. zeromq-dev@lists.zeromq.org
90           mailto:zeromq-dev@lists.zeromq.org
91
92
93
94CZMQ 4.2.1                        01/20/2022                   ZHTTP_SERVER(3)
Impressum