Format an IP,port pair into something easy to parse. If IP is IPv6 * (matches for ":"), the ip is surrounded by []. IP and port are just * separated by colons. This the standard to display addresses within Redis. */
| 591 | * (matches for ":"), the ip is surrounded by []. IP and port are just |
| 592 | * separated by colons. This the standard to display addresses within Redis. */ |
| 593 | int anetFormatAddr(char *buf, size_t buf_len, char *ip, int port) { |
| 594 | return snprintf(buf,buf_len, strchr(ip,':') ? |
| 595 | "[%s]:%d" : "%s:%d", ip, port); |
| 596 | } |
| 597 | |
| 598 | /* Like anetFormatAddr() but extract ip and port from the socket's peer/sockname. */ |
| 599 | int anetFormatFdAddr(int fd, char *buf, size_t buf_len, int fd_to_str_type) { |
no test coverage detected