When i use gethostname it puts the name of my PC in the buffer.
how do i get my host name (or ip address) on the internet rather than on my LAN?

Posted on 2001-08-04 13:25:44 by skud
You can find an example of how to obtain your local IP address in the WinSock FAQ.

Posted on 2001-08-06 07:37:41 by clerihew
i dont know C :(
Posted on 2001-08-06 07:53:53 by skud
There is an example for an IP Dialog showing your computer name and IP address here:


Hope this can help you.
Posted on 2001-08-06 11:45:48 by rir3760
i have written that same program.
i want to get my ip address on the internet, not on my LAN.
as the computer cant tell what ip address is which (or can it??)
i will have to display them all.
how do i do this?

thanks anyway ;)
Posted on 2001-08-06 12:38:35 by skud
skud, if you you're talking dialup, I think there's a connection
enumeration api that will help you - I saw some threads on the
old messageboard. If you're behind a router on a DSL or cable modem
connection, your best bet is probably to ping a server or something.
Posted on 2001-08-06 15:22:51 by f0dder
o yeah i never thought of that.
would the best way be to say "helo" to an smtp server?

and what API is this that you speak of?

Posted on 2001-08-06 16:13:55 by skud
I saw a link to a previous link on here, I have lost the .rc script but I still have the source to a newer version. This one will list all ips avalaible on the machine.
Good day
Posted on 2001-08-06 17:46:53 by Betrayed
f0dder is right. Your pc has network interfaces . Each interface has a different IP address. Most of the times a Windows box has two interfaces. One ethernet and one dialup or other kind of internet access interface.
When dealing with low level networking (i don't mean WinSock) issues you have two choices. You either code your own NDIS compliant driver (given the fact that your win version uses NDIS) or use a third party one.
Coding a driver might be a little bit over your head. So you can take the second option and use a third party driver which will give you mid to high level access to the network interface.

I started a network packet filtering project sometime ago and since i did not want to code my own driver (that would be the project's second part) i decided to use Winpcap .

Give it a try..its open source. So you'll even be able to sneak peek their source code and make your own driver :)
Yes, this post kinda exceeded your needs, but it opens a new world for those who had not delved in the deep waters of packet-level network activity.

I saw once some source code which used the registry to enumerate the interfaces. So it seems there are a couple of diferent ways to get the IPs. Do some research.

Simple server 'conversation' is a piece of cake. Just check Iczelion's Winsock tutorial.
Basically you open a TCP connection to a server on port 25 (for smtp that is) and then proceed according to the Simple Mail Transfer Protocol. Just start with 'HELO' and all that shit :)
Check the SMTP RFC . There are othe addenums to that RFC but just start with that one.

Well..happy diving :)

Posted on 2001-08-06 18:06:28 by latigo
thanks a lot guys!

some good material here for me to get started with.

Posted on 2001-08-07 04:52:59 by skud
Hello skud,

it may be a silly question, but why dont you use winipcfg.exe (or ipconfig on NT) to get your ip address (if thats all you want)?
Posted on 2001-08-09 12:46:20 by japheth
because thats not all i want :)
yeah i could do that and then whenever i need to use the ip address in some program, ask the user to do that and type it in...

but its a bit of an arse really isnt it.

and i want to learn.

why do you use batch files to assemble rather than using the DOS Prompt?


Posted on 2001-08-09 14:58:11 by skud
japheth, that was a dumb thing to say. LOL!
Posted on 2001-08-30 20:36:26 by nin