This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: sockets: problem using h_errno


Hello,

OK, this is a good advice.  I'm using Cygwin 1.1.1.
Anyway, my problem turned out to be a redefinition of h_errno in my program:
   extern int h_errno;
that overwrote the needed
   extern __declspec(dllimport) int h_errno;
from netdb.h.
Removing the wrong line in my code solved the problem.

Thank you, this thread can stop.

	_Olivier_


> -----Original Message-----
> From:	David Robinow [SMTP:drobinow@yahoo.com]
> Sent:	Monday, May 22, 2000 3:46 PM
> To:	Olivier Jacquemin
> Subject:	Re: sockets: problem using h_errno
> 
>  What version of Cygwin are you using?  If I remember
> correctly this was a problem in the original B20.1
> which was fixed around 1 Jul 1999, but I could be
> wrong.  Upgrading might solve your problem. Otherwise,
> I can't help.
>   However, in any case, you should always include your
> version information when reporting a problem.
> --- Olivier Jacquemin
> <Olivier.Jacquemin@DialogSystems.be> wrote:
> > Hello,
> > 
> > I'm trying to compile a C program that was created
> > on Unix.  It uses
> > sockets: one of the source files includes the
> > netdb.h file and uses h_errno
> > to get the error code after a call to
> > getHostByName().  See the code below.
> > 
> > 	#include <netdb.h>	/* getservbyname(),
> > gethostbyname(),HOST_NOT_FOUND */
> > 
> > 	/* CODE SKIPPED */
> > 
> > 	int tcp_open(){
> > 		struct sockaddr_in server;
> > 		struct servent* servp;
> > 		struct hostent* servh;
> > 		
> > 		assert(myFd >= 0);
> > 
> > 		/* get the host address from /etc/hosts */
> > 		if ((servh=gethostbyname(Machine_name)) == NULL){
> > 			
> > 			if (h_errno == HOST_NOT_FOUND){
> > 
> > 	/* CODE SKIPPED */
> > 
> > At compile time, ld complains about an "undefined
> > reference to h_errno" from
> > the last line above.
> > In netdb.h, here is the definition of h_errno (I
> > don't use the
> > -D__INSIDE_CYGWIN_NET__ flag in gcc):
> > 
> > 	#ifdef  __INSIDE_CYGWIN_NET__
> > 	extern int h_errno;
> > 	#else
> > 	extern __declspec(dllimport) int h_errno;
> > 	#endif
> > 
> > At the end of the compilation process, I link the
> > object files against the
> > cygwin library:
> > gcc -Wall -ansi -D__STDC__=0 MsgHandler.o
> > SCPLoadLog.o timeval.o TcpGate.o
> > SCPLoadSim.o -o SCPLoadSim -lcygwin
> > 
> > I thought this library exports h_errno...  Do you
> > have an idea ?
> > I know this could be a very basic question on how to
> > use gcc... sorry if it
> > is so.
> > 
> > Many thanks,
> > 
> > 	_Olivier_
> > 
> > 
> > 
> > --
> > Want to unsubscribe from this list?
> > Send a message to
> > cygwin-unsubscribe@sourceware.cygnus.com
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Send instant messages & get email alerts with Yahoo! Messenger.
> http://im.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]