X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 864C552D90 for ; Mon, 16 May 2005 07:12:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63792-07 for ; Mon, 16 May 2005 10:12:44 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) by svr1.postgresql.org (Postfix) with ESMTP id AB74D53406 for ; Mon, 16 May 2005 07:12:34 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so2180410wri for ; Mon, 16 May 2005 03:12:37 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=R05xM8ci+MHvirDtvI9HSTnhOtGNBoy4gkcykYSLRzFHEfHA1MhBP4FLN0p4w6fRz39NEQll5GwomgxSLd4CdeVPytIQldcXOsG66pQUvYaoqJaB4A6fHxT+ALRAtKdq2gv4pTI/lztEVL5vurQblRi1RZW7f+gk0v5OdVk0yw8= Received: by 10.54.51.45 with SMTP id y45mr3589096wry; Mon, 16 May 2005 03:12:37 -0700 (PDT) Received: by 10.54.30.45 with HTTP; Mon, 16 May 2005 03:12:37 -0700 (PDT) Message-ID: <7104a73705051603121f1c35ab@mail.gmail.com> Date: Mon, 16 May 2005 13:12:37 +0300 From: Volkan YAZICI Reply-To: Volkan YAZICI To: PostgreSQL Interfaces Subject: Network Byte Order Coercion Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.329 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/37 X-Sequence-Number: 5540 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 =3D 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 =3D 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.