Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Fri, 17 Jun 2005 12:24:23 -0400 From: "Fernando Barsoba" Subject: Re: inet_pton() error. Does Cygwin support inet_pton()? To: Message-id: <00db01c57359$0614fed0$0302a8c0@SERVER> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original Content-transfer-encoding: 8BIT X-IsSubscribed: yes Thanks for the code to René...! I'll try it right away..! Thanks again, Fernando cygwin-help AT cygwin DOT com wrote: If you don't need IPv6 in your application you can add tbe following implementation: #ifdef __CYGWIN__ /* From: * UNIX Network Programming: Sockets Introduction * By Andrew M. Rudoff, Bill Fenner, W. Richard Stevens. * Prentice Hall PTR. Feb 27, 2004. */ #define INET_ADDRSTRLEN 16 /* for IPv4 dotted-decimal */ int inet_pton(int family, const char *strptr, void *addrptr) { if (family == AF_INET) { struct in_addr in_val; if (inet_aton(strptr, &in_val)) { memcpy(addrptr, &in_val, sizeof(struct in_addr)); return (1); } return (0); } errno = EAFNOSUPPORT; return (-1); } const char *inet_ntop(int family, const void *addrptr, char *strptr, size_t len) { const u_char *p = (const u_char *) addrptr; if (family == AF_INET) { char temp[INET_ADDRSTRLEN]; snprintf(temp, sizeof(temp), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); if (strlen(temp) >= len) { errno = ENOSPC; return (NULL); } strcpy(strptr, temp); return (strptr); } errno = EAFNOSUPPORT; return (NULL); } #endif I've used this and getaddrinfo() from the postgress port to compile clamsmtpd, and it works fine. HTH, -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/