zhttp_server(3)

zhttp_server(3)

CZMQ Manual - CZMQ/2.2.1

Name

zhttp_server - Class for no title found

Synopsis

//  This is a draft class, and may change without notice. It is disabled in
//  stable builds by default. If you use this in applications, please ask
//  for it to be pushed to stable state. Use --enable-drafts to enable.
#ifdef CZMQ_BUILD_DRAFT_API
//  *** Draft method, for development use, may change without warning ***
//  Create a new http server
CZMQ_EXPORT zhttp_server_t *
    zhttp_server_new (zhttp_server_options_t *options);

//  *** Draft method, for development use, may change without warning ***
//  Destroy an http server
CZMQ_EXPORT void
    zhttp_server_destroy (zhttp_server_t **self_p);

//  *** Draft method, for development use, may change without warning ***
//  Return the port the server is listening on.
CZMQ_EXPORT int
    zhttp_server_port (zhttp_server_t *self);

//  *** Draft method, for development use, may change without warning ***
//  Self test of this class.
CZMQ_EXPORT void
    zhttp_server_test (bool verbose);

#endif // CZMQ_BUILD_DRAFT_API
Please add '@interface' section in './../src/zhttp_server.c'.

Description

zhttp_server -

Please add @discuss section in ./../src/zhttp_server.c.

Example

From zhttp_server_test method

int port = 40000 + (randof (10000));
zhttp_server_options_t *options = zhttp_server_options_new ();
zhttp_server_options_set_port (options, port);

zhttp_server_t *server = zhttp_server_new (options);
assert (server);
zsock_t *worker = zsock_new_dealer (zhttp_server_options_backend_address (options));
zhttp_request_t *request = zhttp_request_new ();
void *connection = zhttp_request_recv (request, worker);
assert (connection);

assert (streq (zhttp_request_method (request), "POST"));
assert (streq (zhttp_request_url (request), "/"));
assert (streq (zhttp_request_content (request), "Hello!"));

zhttp_response_t *response = zhttp_response_new ();
zhttp_response_set_content_const (response, "Welcome!");
zhttp_response_set_status_code (response, 200);
rc = zhttp_response_send (response, worker, &connection);
assert (rc == 0);
zhttp_request_destroy (&request);
zhttp_response_destroy (&response);
zsock_destroy (&worker);
zhttp_server_destroy (&server); zhttp_server_options_destroy (&options);

Authors

The CZMQ manual was written by Pieter Hintjens<moc.xitami|hp#moc.xitami|hp>.

Resources

Main web site: http://czmq.zeromq.org/

Report bugs to the ØMQ development mailing list: <gro.qmorez.stsil|ved-qmorez#gro.qmorez.stsil|ved-qmorez>

Copyright

Copyright (c) 1991-2014 iMatix and Contributors. License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>. This is free software: you are free to change it and redistribute it. There is NO WARRANTY, to the extent permitted by law. For details see the files COPYING and COPYING.LESSER included with the CZMQ distribution.