Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
6a3d01ee
Commit
6a3d01ee
authored
Jul 22, 2016
by
Deomid Ryabkov
Committed by
Cesanta Bot
Jul 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Depend on v7.c properly
PUBLISHED_FROM=cf49d0d345e4a7607c535f9578b8ed4160f2fccd
parent
27986213
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
66 additions
and
66 deletions
+66
-66
mg_add_sock.md
docs/c-api/net.h/mg_add_sock.md
+2
-2
mg_add_sock_opt.md
docs/c-api/net.h/mg_add_sock_opt.md
+2
-2
mg_bind.md
docs/c-api/net.h/mg_bind.md
+1
-1
mg_bind_opt.md
docs/c-api/net.h/mg_bind_opt.md
+7
-7
mg_broadcast.md
docs/c-api/net.h/mg_broadcast.md
+3
-3
mg_check_ip_acl.md
docs/c-api/net.h/mg_check_ip_acl.md
+6
-6
mg_connect.md
docs/c-api/net.h/mg_connect.md
+1
-1
mg_connect_opt.md
docs/c-api/net.h/mg_connect_opt.md
+10
-10
mg_enable_javascript.md
docs/c-api/net.h/mg_enable_javascript.md
+4
-4
mg_enable_multithreading.md
docs/c-api/net.h/mg_enable_multithreading.md
+3
-3
mg_event_handler_t.md
docs/c-api/net.h/mg_event_handler_t.md
+1
-1
mg_mgr_free.md
docs/c-api/net.h/mg_mgr_free.md
+2
-2
mg_mgr_init.md
docs/c-api/net.h/mg_mgr_init.md
+3
-3
mg_mgr_poll.md
docs/c-api/net.h/mg_mgr_poll.md
+4
-4
mg_next.md
docs/c-api/net.h/mg_next.md
+3
-3
mg_printf.md
docs/c-api/net.h/mg_printf.md
+1
-1
mg_send.md
docs/c-api/net.h/mg_send.md
+1
-1
mg_set_ssl.md
docs/c-api/net.h/mg_set_ssl.md
+6
-6
mg_set_timer.md
docs/c-api/net.h/mg_set_timer.md
+4
-4
mg_socketpair.md
docs/c-api/net.h/mg_socketpair.md
+2
-2
No files found.
docs/c-api/net.h/mg_add_sock.md
View file @
6a3d01ee
...
@@ -6,8 +6,8 @@ signature: |
...
@@ -6,8 +6,8 @@ signature: |
struct mg_connection *mg_add_sock(struct mg_mgr *, sock_t, mg_event_handler_t);
struct mg_connection *mg_add_sock(struct mg_mgr *, sock_t, mg_event_handler_t);
---
---
Create
s a connection, associates it with the given socket and event handler
Create
a connection, associate it with the given socket and event handler,
and add
s
it to the manager.
and add it to the manager.
For more options see the
`mg_add_sock_opt`
variant.
For more options see the
`mg_add_sock_opt`
variant.
docs/c-api/net.h/mg_add_sock_opt.md
View file @
6a3d01ee
...
@@ -8,8 +8,8 @@ signature: |
...
@@ -8,8 +8,8 @@ signature: |
struct mg_add_sock_opts);
struct mg_add_sock_opts);
---
---
Create
s a connection, associates it with the given socket and event handler
Create
a connection, associate it with the given socket and event handler,
and add
s
to the manager.
and add to the manager.
See the
`mg_add_sock_opts`
structure for a description of the options.
See the
`mg_add_sock_opts`
structure for a description of the options.
docs/c-api/net.h/mg_bind.md
View file @
6a3d01ee
...
@@ -7,7 +7,7 @@ signature: |
...
@@ -7,7 +7,7 @@ signature: |
mg_event_handler_t);
mg_event_handler_t);
---
---
Create
s a
listening connection.
Create listening connection.
See
`mg_bind_opt`
for full documentation.
See
`mg_bind_opt`
for full documentation.
docs/c-api/net.h/mg_bind_opt.md
View file @
6a3d01ee
...
@@ -8,19 +8,19 @@ signature: |
...
@@ -8,19 +8,19 @@ signature: |
struct mg_bind_opts opts);
struct mg_bind_opts opts);
---
---
Create
s a
listening connection.
Create listening connection.
The
`address`
parameter specifie
s which address to bind to. It's format is the same
`address`
parameter tell
s which address to bind to. It's format is the same
as for the
`mg_connect()`
call, where
`HOST`
part is optional.
`address`
as for the
`mg_connect()`
call, where
`HOST`
part is optional.
`address`
can
just be
a port number, e.g.
`:8000`
. To bind to a specific interface,
can
be just
a port number, e.g.
`:8000`
. To bind to a specific interface,
an IP address can be specified, e.g.
`1.2.3.4:8000`
. By default, a TCP
an IP address can be specified, e.g.
`1.2.3.4:8000`
. By default, a TCP
connection is created. To create
a UDP connection, prepend a
`udp://`
prefix,
connection is created. To create
UDP connection, prepend
`udp://`
prefix,
e.g.
`udp://:8000`
. To summari
se, the
`address`
paramer has following format:
e.g.
`udp://:8000`
. To summari
ze,
`address`
paramer has following format:
`[PROTO://][IP_ADDRESS]:PORT`
, where
`PROTO`
could be
`tcp`
or
`udp`
.
`[PROTO://][IP_ADDRESS]:PORT`
, where
`PROTO`
could be
`tcp`
or
`udp`
.
See the
`mg_bind_opts`
structure for a description of the optional
See the
`mg_bind_opts`
structure for a description of the optional
parameters.
parameters.
Return
s a new listening connection
or
`NULL`
on error.
Return
a new listening connection,
or
`NULL`
on error.
NOTE:
The c
onnection remains owned by the manager, do not free().
NOTE:
C
onnection remains owned by the manager, do not free().
docs/c-api/net.h/mg_broadcast.md
View file @
6a3d01ee
...
@@ -6,14 +6,14 @@ signature: |
...
@@ -6,14 +6,14 @@ signature: |
void mg_broadcast(struct mg_mgr *, mg_event_handler_t func, void *, size_t);
void mg_broadcast(struct mg_mgr *, mg_event_handler_t func, void *, size_t);
---
---
Pass
es
a message of a given length to all connections.
Pass a message of a given length to all connections.
Must be called from a thread that does NOT call
`mg_mgr_poll()`
.
Must be called from a thread that does NOT call
`mg_mgr_poll()`
.
Note that
`mg_broadcast()`
is the only function
Note that
`mg_broadcast()`
is the only function
that can be, and must be, called from a different (non-IO) thread.
that can be, and must be, called from a different (non-IO) thread.
`func`
callback function will be called by the IO thread for each
`func`
callback function will be called by the IO thread for each
connection. When called,
the event will be
`MG_EV_POLL`
, and a
message will
connection. When called,
event would be
`MG_EV_POLL`
, and
message will
be passed as
the
`ev_data`
pointer. Maximum message size is capped
be passed as
`ev_data`
pointer. Maximum message size is capped
by
`MG_CTL_MSG_MESSAGE_SIZE`
which is set to 8192 bytes.
by
`MG_CTL_MSG_MESSAGE_SIZE`
which is set to 8192 bytes.
docs/c-api/net.h/mg_check_ip_acl.md
View file @
6a3d01ee
...
@@ -6,22 +6,22 @@ signature: |
...
@@ -6,22 +6,22 @@ signature: |
int mg_check_ip_acl(const char *acl, uint32_t remote_ip);
int mg_check_ip_acl(const char *acl, uint32_t remote_ip);
---
---
Verif
ies
given IP address against the ACL.
Verif
y
given IP address against the ACL.
`remote_ip`
- an IPv4 address to check, in host byte order
`remote_ip`
- an IPv4 address to check, in host byte order
`acl`
- a comma separated list of IP subnets:
`x.x.x.x/x`
or
`x.x.x.x`
.
`acl`
- a comma separated list of IP subnets:
`x.x.x.x/x`
or
`x.x.x.x`
.
Each subnet is
Each subnet is
prepended by either a - or a + sign. A plus sign means allow, where a
prepended by either a - or a + sign. A plus sign means allow, where a
minus sign means deny. If a subnet mask is omitted, such as
`-1.2.3.4`
,
minus sign means deny. If a subnet mask is omitted, such as
`-1.2.3.4`
,
it means that only that single IP address is denied
.
this means to deny only that single IP address
.
Subnet masks may vary from 0 to 32, inclusive. The default setting
Subnet masks may vary from 0 to 32, inclusive. The default setting
is to allow all access. On each request the full list is traversed,
is to allow all access
es
. On each request the full list is traversed,
and the last match wins. Example:
and the last match wins. Example:
`-0.0.0.0/0,+192.168/16`
- deny all acccesses, only allow 192.168/16 subnet
`-0.0.0.0/0,+192.168/16`
- deny all acccesses, only allow 192.168/16 subnet
To learn more about subnet masks, see th
is
To learn more about subnet masks, see th
e
link:https://en.wikipedia.org/wiki/Subnetwork
[
Wikipedia page on Subnetwork
]
.
link:https://en.wikipedia.org/wiki/Subnetwork
[
Wikipedia page on Subnetwork
]
Return
s
-1 if ACL is malformed, 0 if address is disallowed, 1 if allowed.
Return -1 if ACL is malformed, 0 if address is disallowed, 1 if allowed.
docs/c-api/net.h/mg_connect.md
View file @
6a3d01ee
...
@@ -7,7 +7,7 @@ signature: |
...
@@ -7,7 +7,7 @@ signature: |
mg_event_handler_t handler);
mg_event_handler_t handler);
---
---
Connect
s
to a remote host.
Connect to a remote host.
See
`mg_connect_opt()`
for full documentation.
See
`mg_connect_opt()`
for full documentation.
docs/c-api/net.h/mg_connect_opt.md
View file @
6a3d01ee
...
@@ -8,11 +8,11 @@ signature: |
...
@@ -8,11 +8,11 @@ signature: |
struct mg_connect_opts opts);
struct mg_connect_opts opts);
---
---
Connect
s
to a remote host.
Connect to a remote host.
The
`address`
format is
`[PROTO://]HOST:PORT`
.
`PROTO`
could be
`tcp`
or
`udp`
.
`address`
format is
`[PROTO://]HOST:PORT`
.
`PROTO`
could be
`tcp`
or
`udp`
.
`HOST`
could be an IP address,
`HOST`
could be an IP address,
IPv6 address (if Mongoose is compiled with
`-DMG_ENABLE_IPV6`
) or a host
IPv6 address (if Mongoose is compiled with
`-DMG_ENABLE_IPV6`
)
,
or a host
name. If
`HOST`
is a name, Mongoose will resolve it asynchronously. Examples
name. If
`HOST`
is a name, Mongoose will resolve it asynchronously. Examples
of valid addresses:
`google.com:80`
,
`udp://1.2.3.4:53`
,
`10.0.0.1:443`
,
of valid addresses:
`google.com:80`
,
`udp://1.2.3.4:53`
,
`10.0.0.1:443`
,
`[::1]:80`
`[::1]:80`
...
@@ -20,18 +20,18 @@ of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`,
...
@@ -20,18 +20,18 @@ of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`,
See the
`mg_connect_opts`
structure for a description of the optional
See the
`mg_connect_opts`
structure for a description of the optional
parameters.
parameters.
Returns a new outbound connection or
`NULL`
on error.
Returns a new outbound connection
,
or
`NULL`
on error.
NOTE:
The c
onnection remains owned by the manager, do not free().
NOTE:
C
onnection remains owned by the manager, do not free().
NOTE: To enable IPv6 addresses
`-DMG_ENABLE_IPV6`
should be specified
NOTE: To enable IPv6 addresses
,
`-DMG_ENABLE_IPV6`
should be specified
in the compilation flags.
in the compilation flags.
NOTE:
The new connection will receive
`MG_EV_CONNECT`
as it
s first event
NOTE:
New connection will receive
`MG_EV_CONNECT`
as it'
s first event
which will report
the
connect success status.
which will report connect success status.
If
the asynchronous resolution fails or the
`connect()`
syscall fails
for whatever
If
asynchronous resolution fail, or
`connect()`
syscall fail
for whatever
reason (e.g. with
`ECONNREFUSED`
or
`ENETUNREACH`
), then
`MG_EV_CONNECT`
reason (e.g. with
`ECONNREFUSED`
or
`ENETUNREACH`
), then
`MG_EV_CONNECT`
event
will
report failure. Code example below:
event report failure. Code example below:
```
c
```
c
static
void
ev_handler
(
struct
mg_connection
*
nc
,
int
ev
,
void
*
ev_data
)
{
static
void
ev_handler
(
struct
mg_connection
*
nc
,
int
ev
,
void
*
ev_data
)
{
...
...
docs/c-api/net.h/mg_enable_javascript.md
View file @
6a3d01ee
...
@@ -7,8 +7,8 @@ signature: |
...
@@ -7,8 +7,8 @@ signature: |
const char *init_js_file_name);
const char *init_js_file_name);
---
---
Enable
s
server-side JavaScript scripting.
Enable server-side JavaScript scripting.
Requires
a
`-DMG_ENABLE_JAVASCRIPT`
compilation flag
and V7 engine sources.
Requires
`-DMG_ENABLE_JAVASCRIPT`
compilation flag,
and V7 engine sources.
V
7 instance must not be destroyed during manager's lifetime.
v
7 instance must not be destroyed during manager's lifetime.
Return
s a
V7 error.
Return V7 error.
docs/c-api/net.h/mg_enable_multithreading.md
View file @
6a3d01ee
...
@@ -6,9 +6,9 @@ signature: |
...
@@ -6,9 +6,9 @@ signature: |
void mg_enable_multithreading(struct mg_connection *nc);
void mg_enable_multithreading(struct mg_connection *nc);
---
---
Enable
s
multi-threaded handling for the given listening connection
`nc`
.
Enable multi-threaded handling for the given listening connection
`nc`
.
For each accepted connection, Mongoose will create a separate thread
For each accepted connection, Mongoose will create a separate thread
and run
an event handler in that thread. Thus, if an event hand
ler is doing
and run
event handler in that thread. Thus, if an event han
ler is doing
a blocking call or some long computation,
i
t will not slow down
a blocking call or some long computation,
tha
t will not slow down
other connections.
other connections.
docs/c-api/net.h/mg_event_handler_t.md
View file @
6a3d01ee
...
@@ -7,5 +7,5 @@ signature: |
...
@@ -7,5 +7,5 @@ signature: |
---
---
Callback function (event handler) prototype. Must be defined by the user.
Callback function (event handler) prototype. Must be defined by the user.
Mongoose calls the event handler, passing
the
events defined below.
Mongoose calls the event handler, passing events defined below.
docs/c-api/net.h/mg_mgr_free.md
View file @
6a3d01ee
...
@@ -6,7 +6,7 @@ signature: |
...
@@ -6,7 +6,7 @@ signature: |
void mg_mgr_free(struct mg_mgr *);
void mg_mgr_free(struct mg_mgr *);
---
---
De-initiali
s
es Mongoose manager.
De-initiali
z
es Mongoose manager.
Close
s and deallocates
all active connections.
Close
and deallocate
all active connections.
docs/c-api/net.h/mg_mgr_init.md
View file @
6a3d01ee
...
@@ -6,9 +6,9 @@ signature: |
...
@@ -6,9 +6,9 @@ signature: |
void mg_mgr_init(struct mg_mgr *mgr, void *user_data);
void mg_mgr_init(struct mg_mgr *mgr, void *user_data);
---
---
Initiali
s
e Mongoose manager. Side effect: ignores SIGPIPE signal.
Initiali
z
e Mongoose manager. Side effect: ignores SIGPIPE signal.
`mgr->user_data`
field will be initiali
sed with a
`user_data`
parameter.
`mgr->user_data`
field will be initiali
zed with
`user_data`
parameter.
That is an arbitrary pointer, where
the
user code can associate some data
That is an arbitrary pointer, where user code can associate some data
with the particular Mongoose manager. For example, a C++ wrapper class
with the particular Mongoose manager. For example, a C++ wrapper class
could be written, in which case
`user_data`
can hold a pointer to the
could be written, in which case
`user_data`
can hold a pointer to the
class instance.
class instance.
...
...
docs/c-api/net.h/mg_mgr_poll.md
View file @
6a3d01ee
...
@@ -6,10 +6,10 @@ signature: |
...
@@ -6,10 +6,10 @@ signature: |
time_t mg_mgr_poll(struct mg_mgr *, int milli);
time_t mg_mgr_poll(struct mg_mgr *, int milli);
---
---
This function performs the actual IO and must be called in a loop
This function performs the actual IO
,
and must be called in a loop
(an event loop).
It r
eturns the current timestamp.
(an event loop).
R
eturns the current timestamp.
`milli`
is the maximum number of milliseconds to sleep.
`milli`
is the maximum number of milliseconds to sleep.
`mg_mgr_poll()`
checks all connection
s
for IO readiness. If at least one
`mg_mgr_poll()`
checks all connection for IO readiness. If at least one
of the connections is IO-ready,
`mg_mgr_poll()`
triggers
the
respective
of the connections is IO-ready,
`mg_mgr_poll()`
triggers respective
event handlers and returns.
event handlers and returns.
docs/c-api/net.h/mg_next.md
View file @
6a3d01ee
...
@@ -6,10 +6,10 @@ signature: |
...
@@ -6,10 +6,10 @@ signature: |
struct mg_connection *mg_next(struct mg_mgr *, struct mg_connection *);
struct mg_connection *mg_next(struct mg_mgr *, struct mg_connection *);
---
---
Iterate
s
over all active connections.
Iterate over all active connections.
Returns
the
next connection from the list
Returns next connection from the list
of active connections
or
`NULL`
if there are
no more connections. Below
of active connections
, or
`NULL`
if there is
no more connections. Below
is the iteration idiom:
is the iteration idiom:
```
c
```
c
...
...
docs/c-api/net.h/mg_printf.md
View file @
6a3d01ee
...
@@ -6,7 +6,7 @@ signature: |
...
@@ -6,7 +6,7 @@ signature: |
int mg_printf(struct mg_connection *, const char *fmt, ...);
int mg_printf(struct mg_connection *, const char *fmt, ...);
---
---
Send
s
`printf`
-style formatted data to the connection.
Send
`printf`
-style formatted data to the connection.
See
`mg_send`
for more details on send semantics.
See
`mg_send`
for more details on send semantics.
docs/c-api/net.h/mg_send.md
View file @
6a3d01ee
...
@@ -6,7 +6,7 @@ signature: |
...
@@ -6,7 +6,7 @@ signature: |
void mg_send(struct mg_connection *, const void *buf, int len);
void mg_send(struct mg_connection *, const void *buf, int len);
---
---
Send
s
data to the connection.
Send data to the connection.
Note that sending functions do not actually push data to the socket.
Note that sending functions do not actually push data to the socket.
They just append data to the output buffer. MG_EV_SEND will be delivered when
They just append data to the output buffer. MG_EV_SEND will be delivered when
...
...
docs/c-api/net.h/mg_set_ssl.md
View file @
6a3d01ee
...
@@ -7,15 +7,15 @@ signature: |
...
@@ -7,15 +7,15 @@ signature: |
const char *ca_cert);
const char *ca_cert);
---
---
Note: This function is deprecated
. Please,
use SSL options in mg_connect_opt.
Note: This function is deprecated
, please
use SSL options in mg_connect_opt.
Enable
s
SSL for a given connection.
Enable SSL for a given connection.
`cert`
is a server certificate file name for a listening connection
`cert`
is a server certificate file name for a listening connection
,
or a client certificate file name for an outgoing connection.
or a client certificate file name for an outgoing connection.
The certificate files must be in PEM format. The s
erver certificate file
Certificate files must be in PEM format. S
erver certificate file
must contain a certificate, concatenated with a private key, optionally
must contain a certificate, concatenated with a private key, optionally
concatenated with DH parameters.
concatenated with DH parameters.
`ca_cert`
is a CA certificate or NULL if peer verification is not
`ca_cert`
is a CA certificate
,
or NULL if peer verification is not
required.
required.
Return: NULL on success or error message on error.
Return: NULL on success
,
or error message on error.
docs/c-api/net.h/mg_set_timer.md
View file @
6a3d01ee
...
@@ -6,12 +6,12 @@ signature: |
...
@@ -6,12 +6,12 @@ signature: |
double mg_set_timer(struct mg_connection *c, double timestamp);
double mg_set_timer(struct mg_connection *c, double timestamp);
---
---
Schedule
s an
MG_EV_TIMER event to be delivered at
`timestamp`
time.
Schedule MG_EV_TIMER event to be delivered at
`timestamp`
time.
`timestamp`
is
UNIX time (the
number of seconds since Epoch). It is
`timestamp`
is
a UNIX time (a
number of seconds since Epoch). It is
`double`
instead of
`time_t`
to allow for sub-second precision.
`double`
instead of
`time_t`
to allow for sub-second precision.
Return
s
the old timer value.
Return the old timer value.
Example: set
the
connect timeout to 1.5 seconds:
Example: set connect timeout to 1.5 seconds:
```
```
c = mg_connect(&mgr, "cesanta.com", ev_handler);
c = mg_connect(&mgr, "cesanta.com", ev_handler);
...
...
docs/c-api/net.h/mg_socketpair.md
View file @
6a3d01ee
...
@@ -6,7 +6,7 @@ signature: |
...
@@ -6,7 +6,7 @@ signature: |
int mg_socketpair(sock_t[2], int sock_type);
int mg_socketpair(sock_t[2], int sock_type);
---
---
Create
s
a socket pair.
Create a socket pair.
`sock_type`
can be either
`SOCK_STREAM`
or
`SOCK_DGRAM`
.
`sock_type`
can be either
`SOCK_STREAM`
or
`SOCK_DGRAM`
.
Return
s 0 on failure and
1 on success.
Return
0 on failure,
1 on success.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment