inet_ntop | |
Prototype: |
#include <arpa/inet.h> char* inet_ntop(int domain, struct in_addr *addr, char* str, int len); |
General Description: | This call converts the network-byte order binary to a human-readable form. Unlike the inet_ntoa, you need to supply it a scratchpad string. This function supports both AF_INET and AF_INET6. |
Return Value: | str. |
Parameters | |
domain | The network type (AF_INET or AF_INET6). |
addr | The binary address (typically the address field of struct sockaddr_in). |
str | The string buffer. |
len | The number of bytes available in str. |
Possible Errors | |
(errno not set) | |
Examples | |
char str[100]; clientfd = accept(serverfd, &addr, &addr_size); if ( clientfd > 0 ) printf("Connected %s:%d\n", inet_ntop(AF_INET, addr.sin_addr, str, sizeof(str)), ntohs(addr.sin_port)); (c)Network Addressing Tools |