This is the mail archive of the mailing list for the Guile project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: inet-ntoa and inet-aton byte order question?

| Can someone please tell me why these two functions do implicit htonl()
| and ntohl()?

It makes them compatible with all the other networking stuff that does
the same thing, i.e., you can do (socket ... (inet-ntoa ...)).

| For me this caused a little confusion (until i saw the source :) because
| i expceted them to behave exactly like C library ones.

Not many of the Guile interfaces are exactly like the C library ones.
Among other things they change the argument and return types to Scheme
conventions and throw exceptions instead of returning error values.

| If the behaviour is left as it is, it should at least appear in the
| function documentation.

It's mentioned in the networking intro in the reference manual:

File:,  Node: Network Sockets and Communication,  Prev: Network Databases and Address Conversion,  Up: Networking

Network Sockets and Communication

   Socket ports can be created using `socket' and `socketpair'.  The
ports are initially unbuffered, to makes reading and writing to the
same port more reliable.  A buffer can be added to the port using
`setvbuf', *Note Ports and File Descriptors::.

   The convention used for "host" vs "network" addresses is that
addresses are always held in host order at the Scheme level.  The
procedures in this section automatically convert between host and
network order when required.  The arguments and return values are thus
in host order.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]