mongoose/docs/c-api/net.h/mg_bind_opt.md
Dmitry Frank 0fc3370859 First step towards separate userdata argument
PUBLISHED_FROM=93fe1cc2c5e2513509511a81e5919cbd37056b10
2017-03-15 00:52:59 +00:00

1.0 KiB

title decl_name symbol_kind signature
mg_bind_opt() mg_bind_opt func struct mg_connection *mg_bind_opt(struct mg_mgr *mgr, const char *address, MG_CB(mg_event_handler_t handler, void *user_data);

Creates a listening connection.

The address parameter specifies which address to bind to. It's format is the same as for the mg_connect() call, where HOST part is optional. address 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 connection is created. To create UDP connection, prepend udp:// prefix, e.g. udp://:8000. To summarize, address parameter has following format: [PROTO://][IP_ADDRESS]:PORT, where PROTO could be tcp or udp.

See the mg_bind_opts structure for a description of the optional parameters.

Returns a new listening connection or NULL on error. NOTE: The connection remains owned by the manager, do not free().