inet_pton() error. Does Cygwin support inet_pton()?

Fernando Barsoba
Fri Jun 17 17:38:00 GMT 2005

 Thanks for the code to René...! I'll try it right away..!

Thanks again,

Fernando wrote:

  If you don't need IPv6 in your application you can add tbe following 

  #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], 
         if (strlen(temp) >= len) {
             errno = ENOSPC;
             return (NULL);
         strcpy(strptr, temp);
         return (strptr);
     errno = EAFNOSUPPORT;
     return (NULL);


  I've used this and getaddrinfo() from the postgress port to compile 
  and it works fine.


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list