Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-11

StrToHostAddr

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

Hi all,

The function StrToHostAddr in unit sockets returns for '127.0.0.1' on a little endian system the in_addr:
s_bytes[1]=1
s_bytes[2]=0
s_bytes[3]=0
s_bytes[4]=127

Is this correct?

The documentation for HostAddrToStr writes "Basically, it is the same as NetAddrToStr, but with the bytes in correct order.": http://lazarus-ccr.sourceforge.net/docs/rtl/sockets/hostaddrtostr.html This sounds as if a Net and a Host uses different ordered bytes, which makes the whole point of an "and" mask pointless.

Mattias

Reply by email

Jeppe Græsdal Johansen
to Mattias Gaertner
Mattias Gaertner wrote
This sounds as if a Net and a Host uses different ordered bytes, which makes the whole point of an "and" mask pointless.

Network order is always big endian. Host endian is just the endian of your host computer. So in most cases they are indeed different

I don't know what you mean about and mask

Reply by email

Mattias Gaertner
to Jeppe Græsdal Johansen
Show quoted text 5 lines
Den 05-11-2011 18:01, Mattias Gaertner skrev: > This sounds as if a Net and a Host uses different ordered bytes, which > makes the whole point of an "and" mask pointless. Network order is always big endian. Host endian is just the endian of your host computer. So in most cases they are indeed different

Ah, I confused Network format with Network mask (netmask).

Ok, so StrToHostAddr('1.2.3.4') returns the in_addr in machine order.

I wonder why TSocketStream.RemoteAddress.in_addr is in network order.

I don't know what you mean about and mask

I thought the Host and Net stand for the host and net(-mask) part of a subnet e.g. 1.2.3.4/255.255.255.0.

Mattias

Reply by email