Network Byte Order Coercion

Поиск
Список
Период
Сортировка
От Volkan YAZICI
Тема Network Byte Order Coercion
Дата
Msg-id 7104a73705051603121f1c35ab@mail.gmail.com
обсуждение исходный текст
Список pgsql-interfaces
Hi,

In libpq example program 3 (testlibpq3.c), an int4 field is converted
to host byte order:

{{{
/* Get the field values (we ignore possibility they are null!) */
iptr = PQgetvalue(res, i, i_fnum);

/** The binary representation of INT4 is in network byte order,* which we'd better coerce to the local byte order.*/
ival = ntohl(*((uint32_t *) iptr));
}}}

(As I saw while reading "An Essay on Endian Order" [1]) I'm not so
familiar with byte orders, but what's the point of coercion in here?
Should we do it in every integer field we retrieved? What's the
[dis]advantages of this? I'd be so appreciated for any explanation.

[1] http://www.cs.umass.edu/~verts/cs32/endian.html

Regards.


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Two seperate problems with libpq - arrays and bytea edit
Следующее
От: Christoph Haller
Дата:
Сообщение: Re: Network Byte Order Coercion