delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/16/22:59:35

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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: Thu, 16 Jun 2005 22:59:22 -0400
From: "Fernando Barsoba" <fbarsoba AT verizon DOT net>
Subject: inet_pton() error. Does Cygwin support inet_pton()?
To: <cygwin AT cygwin DOT com>
Message-id: <00a401c572e8$90d2f250$0302a8c0@SERVER>
MIME-version: 1.0

Hello all,

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:

(I apologize in advance if this is not a Cygwin related problem. It's simply 
that I saw a post in which it was mentioned that inet_pton() wasn't 
supported by Cygwin...)

ERROR:
make -k clean all
rm -f newclient.o newserver.o test.o
gcc    -c -o newclient.o newclient.c
gcc newclient.c -o newclient
/cygdrive/f/DOCUME~1/FERNAN~1/LOCALS~1/Temp/ccqoLn6M.o(.text+0xae):newclient.c: 
undefined reference to `_inet_pton'
collect2: ld returned 1 exit status
make: *** [newclient] Error 1
gcc    -c -o newserver.o newserver.c
gcc newserver.c -o newserver
gcc    -c -o test.o test.c
gcc test.c -o test
make: Target `all' not remade because of errors.

As you can see, it seems that the library is misson or something.., but I 
did include it..

CODE:
#include <stdlib.h>
#include <netinet/in.h>
#include <arpa/inet.h> // inet_pton() reference...?
#include <sys/socket.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char **argv)
{
 int sockfd; // socket file descriptor
 struct sockaddr_in servaddr; // IPv4 socket address structure

 //sockfd = socket(AF_INET, SOCK_STREAM, 0); // call to socket function
 printf("Connecting to socket...");
 if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
  printf("Socket Error");
 bzero((char *) &servaddr, sizeof(servaddr)); // initialization of socket 
structure to 0
 servaddr.sin_family = AF_INET;
 servaddr.sin_port = htons(/*9877*/13); // Port in host byte order must be 
converted
          // to network byte order

 if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0)
  printf("\ninet_pton error");

 if (connect(sockfd,( struct sockaddr *) &servaddr, sizeof(servaddr)) < 0)
  printf("\nError connecting to server!");
   // Connection to port 9877, IP?
 exit(0);
}

Any idea?

Thanks,

FBM 



--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019