mongoose/docs/c-api/util.h/mg_conn_addr_to_str.md
Sergey Lyubka 8d76733fad Make mg_conn_addr_to_str return len
Also amend api_net.js to use returned length.

PUBLISHED_FROM=38e15f9587edf28049c5b9e5f126b4db159910e8
2017-06-26 21:02:02 +00:00

735 B

title decl_name symbol_kind signature
mg_conn_addr_to_str() mg_conn_addr_to_str func int mg_conn_addr_to_str(struct mg_connection *c, char *buf, size_t len, int flags);

Converts a connection's local or remote address into string.

The flags parameter is a bit mask that controls the behaviour, see MG_SOCK_STRINGIFY_* definitions.

  • MG_SOCK_STRINGIFY_IP - print IP address
  • MG_SOCK_STRINGIFY_PORT - print port number
  • MG_SOCK_STRINGIFY_REMOTE - print remote peer's IP/port, not local address

If both port number and IP address are printed, they are separated by :. If compiled with -DMG_ENABLE_IPV6, IPv6 addresses are supported. Return length of the stringified address.