From: hamish@waikato.ac.nz
Newsgroups: comp.os.os2.networking,comp.os.os2.programmer
Subject: Re: Accessing tcpipdll from watcom 9.0
Date: 7 Sep 92 09:11:20 +1200
Organization: University of Waikato, Hamilton, New Zealand

From:	IN%"HAMISH@waikato.ac.nz"  "Hamish Marson"  7-SEP-1992 09:07:44.49
To:	hamish@waikato.ac.nz
CC:	
Subj:	Re: Accessing tcpipdll from watcom 9.0

Date: Mon, 7 Sep 92 09:07 +1200
From: Hamish Marson <HAMISH@waikato.ac.nz>
Subject: Re: Accessing tcpipdll from watcom 9.0
To: hamish@waikato.ac.nz
X-VMS-To: in%"hamish@waikato.ac.nz"

>> 
>> I am attempting to use the tcp/ip dll from watcom C/386 9.0 under OS/2 2.0, and
>> have run into a bit of a problem. After adding the __cdecl __far16 combination
>> to the prototypes in the *.h files, I can get such things as sock_init() and
>> socket to work and return values, consistant with what they should. However I
>> can't get the gethostbyname() function to return a decent valid pointer to a
>> bloick of memory (ie the host entry). I have it declared as
>> 
>> struct hostent * __cdecl __far16 gethostbyname(char hostname[]);
>> 

Well. It turns out I'm doing it right. I just got some email from the kind
person at watcom, and have been informed that it is a bug in the watcom
compiler. Heres the mail message I got from him.

***********************

I saw your posting about a problem using gethostbyname with WATCOM C.
You have discovered a bug in the compiler. It refuses to believe that
a function can return a __far16 pointer. I'll pass the problem on
to the C front end developer. In the mean time, I've figured out
a workaround for you. It's a little bit of a kludge, but it's the only
way to get the right code generated. I tried a lot of variations but this
was the only one that worked. Here's the code.

struct hostent * __cdecl __far16 gethostbyname(char*name);
struct hostent *host;

this_works()
{
    struct hostent __far16 * workaround;

    *(long*)&workaround = gethostbyname("hi");
    host = workaround;
}

We make compiler patches available regularly. We'll be releasing patch
level 'C' very soon, and I'll try to make sure that the patch solves
the problem.

Patches can be downloaded from our BBS at (519) 884-2103.

Tech support can be reached at (519) 886-3700 or by sending mail to
tech@watcom.on.ca. They will add you to a list of people to be
notified when the patch becomes available.

Feel free to post this message to the news group if you want.
I'm replying from an MS-DOS box and can't do it easily.

***********************

Thanks to john from watcom for the info.

On another note. Are the watcom patches anywhere on the net? I don't have modem
access to the states and Canada. Could some kind soul upload them to ftp-os2
perhaps?


-- 
==============================================================================
|  Hamish Marson   <h.marson@waikato.ac.nz>                             OS/2 |
|  Programmer (n/5), School of Computing and Mathematical Sciences           | 
|  University of Waikato,                                                    |
|  Hamilton, New Zealand.                                                    |
|Disclaimer:  Anything said in this message is the personal opinion of the   |
|             finger hitting the keyboard & doesn't represent my employers   |
|             opinion in any way. (ie we probably don't agree)               |
==============================================================================
  Q. If Nuclear Tests are so safe, why don't the French do them under Paris?
Xref: sparky comp.os.os2.networking:1269 comp.sys.novell:7116