[drupal-devel] OT: Binary data.

Chris Johnson chris at tinpixel.com
Wed Mar 16 05:57:47 UTC 2005


Gordon Heydon wrote:
> Hello,
> 
> I wish it was, but this is a custom stream to talk to a PICK database to
> extract information for the web.
> 
> The problem that the protocol is proprietary crap which has one binary
> int field at the beginning of the request, and the rest is text based.
> 
> Thanks.
> Gordon.
> 
> On Tue, 2005-03-15 at 13:43 +0100, Karoly Negyesi wrote:
> 
>>>int c;
>>>write(sockfd, c, sizeof(int));
>>>
>>>So what would this be in php.

You do realize that the format of the integer "c" might well be different on 
the writing system and on the receiving system, don't you?  Big endian versus 
little endian, or 2's-complement versus 1's-complment, for example.

This is why RPC libraries always define external data formats (XDF), so that 
every process agrees on the same 4-byte representation of an integer.

Having said that, take a look at the socket_send() page in the user comments. 
  I think you will have to do your own conversion of the integer into 4 bytes 
and then send them.

--
Chris Johnson




More information about the drupal-devel mailing list