return 0;
}
+int net_getpeername(int fd, struct ip_addr *addr, unsigned int *port)
+{
+ union sockaddr_union so;
+ socklen_t addrlen;
+
+ i_assert(fd >= 0);
+
+ addrlen = sizeof(so);
+ if (getpeername(fd, (struct sockaddr *) &so, &addrlen) == -1)
+ return -1;
+
+ if (addr != NULL) sin_get_ip(&so, addr);
+ if (port != NULL) *port = sin_get_port(&so);
+
+ return 0;
+}
+
const char *net_ip2addr(const struct ip_addr *ip)
{
#ifdef HAVE_IPV6
some error with name server) */
int net_hosterror_notfound(int error);
-/* Get socket address/port */
+/* Get socket local address/port */
int net_getsockname(int fd, struct ip_addr *addr, unsigned int *port);
+/* Get socket remote address/port */
+int net_getpeername(int fd, struct ip_addr *addr, unsigned int *port);
/* Returns ip_addr as string, or NULL if ip is invalid. */
const char *net_ip2addr(const struct ip_addr *ip);