2016-05-12 04:36:12 +08:00
|
|
|
---
|
|
|
|
title: "mg_bind_opt()"
|
|
|
|
decl_name: "mg_bind_opt"
|
|
|
|
symbol_kind: "func"
|
|
|
|
signature: |
|
|
|
|
struct mg_connection *mg_bind_opt(struct mg_mgr *mgr, const char *address,
|
|
|
|
mg_event_handler_t handler,
|
|
|
|
struct mg_bind_opts opts);
|
|
|
|
---
|
|
|
|
|
2016-07-22 20:37:46 +08:00
|
|
|
Create listening connection.
|
2016-05-12 04:36:12 +08:00
|
|
|
|
2016-07-22 20:37:46 +08:00
|
|
|
`address` parameter tells which address to bind to. It's format is the same
|
2016-05-12 04:36:12 +08:00
|
|
|
as for the `mg_connect()` call, where `HOST` part is optional. `address`
|
2016-07-22 20:37:46 +08:00
|
|
|
can be just a port number, e.g. `:8000`. To bind to a specific interface,
|
2016-05-12 04:36:12 +08:00
|
|
|
an IP address can be specified, e.g. `1.2.3.4:8000`. By default, a TCP
|
2016-07-22 20:37:46 +08:00
|
|
|
connection is created. To create UDP connection, prepend `udp://` prefix,
|
|
|
|
e.g. `udp://:8000`. To summarize, `address` paramer has following format:
|
2016-05-12 04:36:12 +08:00
|
|
|
`[PROTO://][IP_ADDRESS]:PORT`, where `PROTO` could be `tcp` or `udp`.
|
|
|
|
|
|
|
|
See the `mg_bind_opts` structure for a description of the optional
|
|
|
|
parameters.
|
|
|
|
|
2016-07-22 20:37:46 +08:00
|
|
|
Return a new listening connection, or `NULL` on error.
|
|
|
|
NOTE: Connection remains owned by the manager, do not free().
|
2016-05-12 04:36:12 +08:00
|
|
|
|