diff options
author | Joseph Henry <joseph.henry@gmail.com> | 2015-10-27 17:12:32 -0700 |
---|---|---|
committer | Joseph Henry <joseph.henry@gmail.com> | 2015-10-27 17:12:32 -0700 |
commit | 721d58b464e5fa612b4f7cb4e91b9dca629e69a9 (patch) | |
tree | 80602a231fefd3fea79ce5ff1c9a5f3bf5ffd10e /netcon/Common.c | |
parent | 8cfee8a38c5d45242a52eb2f03a8aba97ed51a3e (diff) | |
download | infinitytier-721d58b464e5fa612b4f7cb4e91b9dca629e69a9.tar.gz infinitytier-721d58b464e5fa612b4f7cb4e91b9dca629e69a9.zip |
Added support for Redis
Diffstat (limited to 'netcon/Common.c')
-rwxr-xr-x | netcon/Common.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/netcon/Common.c b/netcon/Common.c index beb530c6..59d6648f 100755 --- a/netcon/Common.c +++ b/netcon/Common.c @@ -48,6 +48,28 @@ void dwr(const char *fmt, ...); extern pthread_mutex_t loglock; +void print_addr(struct sockaddr *addr) +{ + char *s = NULL; + switch(addr->sa_family) { + case AF_INET: { + struct sockaddr_in *addr_in = (struct sockaddr_in *)addr; + s = malloc(INET_ADDRSTRLEN); + inet_ntop(AF_INET, &(addr_in->sin_addr), s, INET_ADDRSTRLEN); + break; + } + case AF_INET6: { + struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr; + s = malloc(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, &(addr_in6->sin6_addr), s, INET6_ADDRSTRLEN); + break; + } + default: + break; + } + fprintf(stderr, "IP address: %s\n", s); + free(s); +} #ifdef NETCON_SERVICE |