Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtained IP, but not right, some kind of conversion? 1

Status
Not open for further replies.

sph147

Programmer
May 17, 2004
19
US
I get information about an Ethernet device on my computer using a function call that returns a sockaddr* struct. when i output the sa_data in that struct and expect to get my IP (should be a 192.x.x.x cause i'm off a local switch) and my netmask, i'm getting numbers like
"1694607552" for IP and
"16777215" for netmask
I'm almost sure the sockaddr is holding that info because another similair program retrievs the correct info from the same function call, but I don't know how. Am I missing something obvious? Why isn't the number even close to correct? And how can I get it into the familiar dotted notation?? Thank you for any help.
 
Well

[tt]1694607552[/tt] decimal
is
[tt]6501A8C0[/tt] hexadecimal

Reading from right-to-left, you have
[tt]C0 = 192
A8 = 168
01 = 1
65 = 101[/tt]

Basically, you need to use things to extract individual bytes out of an unsigned long.

--
 
I wish it would have been more complicated so I felt better about not getting it, but either way, thanks a million.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top