diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-01-24 17:38:16 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-02-01 16:11:38 -0800 |
| commit | 3dae30ed5e543dc73fc993334ef56b9b157b9b3c (patch) | |
| tree | d7e294b5d544aa18e8fc8749abfe605a05fa4bd7 /src/nng.c | |
| parent | 5914e40c2ff7fcf346c90705785f3fb7650a9fdc (diff) | |
| download | nng-3dae30ed5e543dc73fc993334ef56b9b157b9b3c.tar.gz nng-3dae30ed5e543dc73fc993334ef56b9b157b9b3c.tar.bz2 nng-3dae30ed5e543dc73fc993334ef56b9b157b9b3c.zip | |
fixes #173 Define public HTTP server API
This introduces enough of the HTTP API to support fully server
applications, including creation of websocket style protocols,
pluggable handlers, and so forth.
We have also introduced scatter/gather I/O (rudimentary) for
aios, and made other enhancements to the AIO framework. The
internals of the AIOs themselves are now fully private, and we
have eliminated the aio->a_addr member, with plans to remove the
pipe and possibly message members as well.
A few other minor issues were found and fixed as well.
The HTTP API includes request, response, and connection objects,
which can be used with both servers and clients. It also defines
the HTTP server and handler objects, which support server applications.
Support for client applications will require a client object to be
exposed, and that should be happening shortly.
None of this is "documented" yet, bug again, we will follow up shortly.
Diffstat (limited to 'src/nng.c')
| -rw-r--r-- | src/nng.c | 69 |
1 files changed, 41 insertions, 28 deletions
@@ -9,6 +9,7 @@ // #include "core/nng_impl.h" +#include "supplemental/http/http.h" // This file provides the "public" API. This is a thin wrapper around // internal API functions. We use the public prefix instead of internal, @@ -179,9 +180,8 @@ nng_sendmsg(nng_socket sid, nng_msg *msg, int flags) } void -nng_recv_aio(nng_socket sid, nng_aio *ap) +nng_recv_aio(nng_socket sid, nng_aio *aio) { - nni_aio * aio = (nni_aio *) ap; nni_sock *sock; int rv; @@ -194,9 +194,8 @@ nng_recv_aio(nng_socket sid, nng_aio *ap) } void -nng_send_aio(nng_socket sid, nng_aio *ap) +nng_send_aio(nng_socket sid, nng_aio *aio) { - nni_aio * aio = (nni_aio *) ap; nni_sock *sock; int rv; @@ -1019,73 +1018,87 @@ nng_msg_getopt(nng_msg *msg, int opt, void *ptr, size_t *szp) int nng_aio_alloc(nng_aio **app, void (*cb)(void *), void *arg) { - nni_aio *aio; + nng_aio *aio; int rv; if ((rv = nni_init()) != 0) { return (rv); } if ((rv = nni_aio_init(&aio, (nni_cb) cb, arg)) == 0) { - *app = (nng_aio *) aio; + nng_aio_set_timeout(aio, NNG_DURATION_DEFAULT); + *app = aio; } - aio->a_timeout = NNG_DURATION_DEFAULT; return (rv); } void -nng_aio_free(nng_aio *ap) +nng_aio_free(nng_aio *aio) { - nni_aio_fini((nni_aio *) ap); + nni_aio_fini(aio); } int -nng_aio_result(nng_aio *ap) +nng_aio_result(nng_aio *aio) { - return (nni_aio_result((nni_aio *) ap)); + return (nni_aio_result(aio)); +} + +size_t +nng_aio_count(nng_aio *aio) +{ + return (nni_aio_count(aio)); } void -nng_aio_stop(nng_aio *ap) +nng_aio_stop(nng_aio *aio) { - nni_aio_stop((nni_aio *) ap); + nni_aio_stop(aio); } void -nng_aio_wait(nng_aio *ap) +nng_aio_wait(nng_aio *aio) { - nni_aio_wait((nni_aio *) ap); + nni_aio_wait(aio); } void -nng_aio_cancel(nng_aio *ap) +nng_aio_cancel(nng_aio *aio) { - nni_aio_cancel((nni_aio *) ap, NNG_ECANCELED); + nni_aio_abort(aio, NNG_ECANCELED); } void -nng_aio_set_msg(nng_aio *ap, nng_msg *msg) +nng_aio_set_msg(nng_aio *aio, nng_msg *msg) { - nni_aio_set_msg((nni_aio *) ap, msg); + nni_aio_set_msg(aio, msg); } nng_msg * -nng_aio_get_msg(nng_aio *ap) +nng_aio_get_msg(nng_aio *aio) { - return ((nng_msg *) (nni_aio_get_msg((nni_aio *) ap))); + return (nni_aio_get_msg(aio)); } void -nng_aio_set_timeout(nng_aio *ap, nng_duration dur) +nng_aio_set_timeout(nng_aio *aio, nni_duration when) +{ + nni_aio_set_timeout(aio, when); +} + +int +nng_aio_set_iov(nng_aio *aio, int niov, nng_iov *iov) { - // Durations here are relative, since we have no notion of a - // common clock.. - nni_aio_set_timeout((nni_aio *) ap, dur); + return (nni_aio_set_iov(aio, niov, iov)); } int -nng_aio_set_iov(nng_aio *ap, int niov, nng_iov *iov) +nng_aio_set_input(nng_aio *aio, unsigned index, void *arg) { - return (nni_aio_set_iov((nni_aio *) ap, niov, iov)); + if (index > 3) { + return (NNG_EINVAL); + } + nni_aio_set_input(aio, index, arg); + return (0); } #if 0 @@ -1199,4 +1212,4 @@ int nng_url_clone(nng_url **dstp, const nng_url *src) { return (nni_url_clone(dstp, src)); -}
\ No newline at end of file +} |
