Technical article 127297

Get "Unknown host" error using gethostbyname(SLIB-osr5) on OpenServer 6.0.0

OpenServer 6.0.0

Written · Last revised

Problem

I have an application source that compiles and works correctly on SCO OpenServer 5. However, if I compile the application on SCO OpenServer 6.0.0 and run it then gethostbyname(SLIB-osr5) fails with an "Unknown host" error. The host that gethostbyname is trying to resolve is not resolvable with DNS.

Cause

In OpenServer 5, if the name passed to gethostbyname is an ASCII string that is a printable version of a valid ip address, then gethostbyname returns a faked up hostent entry with that ip address if the IP address is not resolvable.

In OpenServer 6.0.0, gethostbyname doesn't do that.

Solution

There are two possible workarounds to this problem:

1) Compile the application on OpenServer 6.0.0 using the OpenServer 5 ABI (-K osr)

For example, if your source is called foobar.c then compile it as follows:

# cc foobar.c -lsocket -K osr -o foobar.osr5

2) Compile the application on OpenServer 6.0.0 and link against libresolv.so.

Using the foobar.c example above, compile as follows:

# cc foobar.c -lresolv -lsocket -o foobar

From the Xinuos technical article database, record 127297. Reproduced with permission. The original is at www.sco.com/ta/127297, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.