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 To: cygwin AT cygwin DOT com From: =?ISO-8859-1?Q?Ren=E9_Berber?= Subject: Re: inet_pton() error. Does Cygwin support inet_pton()? Date: Fri, 17 Jun 2005 09:35:59 -0500 Lines: 60 Message-ID: References: <00a401c572e8$90d2f250$0302a8c0 AT SERVER> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) In-Reply-To: <00a401c572e8$90d2f250$0302a8c0@SERVER> X-IsSubscribed: yes Fernando Barsoba wrote: > > I'm trying to use the function inet_pton(), but I found the following > error when trying to build the application with Eclipse/CDT on Cygwin: [snip] 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, -- René Berber -- 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/