This is the mail archive of the cygwin 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]
Other format: [Raw text]

RE: pthreads and sockets - Cannot register window class error


> From: Christopher Faylor
> Sent: Wednesday, May 05, 2004 11:04 PM

> On Wed, May 05, 2004 at 05:38:35AM -0700, Brian Dessent wrote:
> >Jacek Trzmiel wrote:
> >
> >> void test()
> >> {
> >>     /* go find out about the desired host machine */
> >>     struct hostent *he = gethostbyname(HOST);
> >>     if (he == 0) {
> >>         perror("gethostbyname");
> >>         exit(1);
> >>     }
> >
> >Just a wild guess, but gethostbyname() is probably not reentrant and
> >can't be called from threads like that.
>
> Unless HOST is a numeric IP address, gethostbyname should be properly
> reentrant.  The only time gethostbyname is not thread safe is when it is
> resolving a numeric IP.
>
> cgf

 Is this specifically for cygwin, or common place?

Trying to find out -> /MORE - not so cygwin'ish follows/


The following indicates to me that numeric, i.e. dotted decimal input,
causes unspecified behaviour:

http://www.opengroup.org/onlinepubs/009695399/functions/gethostbyaddr.html
> The name argument of gethostbyname() shall be a node name; the behavior
> of gethostbyname() when passed a numeric address string is unspecified.
> For IPv4, a numeric address string shall be in the dotted-decimal notation
> described in inet_addr() .

 IMO the middle of this paragraph is incongruous! WHAT are they trying to
say?

Besides this they seem to be saying that nothing has to be reentrant nor
thread safe.

...and then there is:

> The getaddrinfo() and getnameinfo() functions are preferred over the
> gethostbyaddr() and gethostbyname() functions.

/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E

** on a mailing list; please keep replies on that particular list **

-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--


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


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