delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/06/14:17:10

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Winsock getting dynamic IP
Date: Tue, 06 Jan 1998 18:30:03 GMT
Organization: [posted via] Easynet UK
Lines: 38
Message-ID: <34b0e1a5.3820592@news.easynet.co.uk>
References: <01bd079b$c810a020$63206ccb AT ashod>
NNTP-Posting-Host: foot.easynet.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 2 Jan 1998 06:48:27 GMT, "Ashod" <ashod AT ozemail DOT com DOT au> wrote:

>Hello , there seems to be a problem getting the dynamic ip address
>of a connection using djgpp winsock..
>
>A possible solution is to pipe the output ( if this is possible ) of
>winpcfg.exe

Maybe.  Another way is to contact someone and do a getsockname on the
socket -- but you need someone to contact first.  If you have for
example a DNS server's IP (which you probably want anyway), you could
contact the DNS server and read off your own IP.  But this requires
you to know your DNS servers' IP addresses.

If you have BOOTP, you can use that -- Dan Hedlund has some code to
get your IP address and DNS servers' addresses in this way, see his
WSOCK library, linked from
http://www.delorie.com/djgpp/dl/elsewhere.html.

A better way is to get the information from the Win95 registry.  I
tried to do this a while ago but didn't get any sane response from the
registry vxd; it seems that it accepts calls from protected mode
without crashing, but doesn't understand any parameters passed that
way.  You have to pass all your parameters via conventional memory,
and call it through __dpmi_simulate_real_mode_procedure_retf.

When you've got the registry reader working, there's still a bit more
work to do -- first you have to look up some keys to decide whether
the connection is RAS or not.  If it's RAS, you have to decode a
status block, which contains the IP address and DNS server IP
addresses, among other things.  If it's not RAS, life's a bit simpler;
you just have to find the connection that's active and read a few keys
which contain the IP and DNS server addresses.

A guy called Alfons Hoogervorst has this working for protected mode
Watcom and Symantec, and for real-mode DOS; I'm porting his code to
djgpp at the moment.  I'll let you know if/when it finally works.

- Raw text -


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