[drupal-devel] OT: Binary data.

Mark mark at nullcraft.org
Tue Mar 15 14:22:36 UTC 2005

Gordon Heydon wrote:

>I know that this may be a little off topic, but I know most people here
>deal with php most of the time. I need to write a little test suite, and
>the only thing that is stopping this from being easy is that I need to
>know how to write a raw integer (4 binary chars) into a socket.
>I can do this with c, it is just...
>int c;
>write(sockfd, c, sizeof(int));
>So what would this be in php.
>I was wondering if someone can shed some light on it.
>Thanks in advance.
I have experience interfacing with a PICK system.  It was running on an 
ancient Digital Unix box without a modern compiler, so without a serious 
upgrade, very few options existed.  I ended up writing a minimalistic 
HTTP server in C that spoke via UNIX file sockets to a PICK process.  
The beauty of this solution for me was that I could accommodate a 
clueless PICK developer.  All she had to do was open a "file" and read.  
When a newline came in, she would process the data packet. I did all of 
my heavy logic in a Python script on a remote server (yours would be a 
drupal server).

Since then, I know PICK was movinig toward Linux support, and you might 
be able to use php to write to/read from a Unix file socket from a local 
apache/php server.  I was sending financial transaction data using this 
connection method, and there was a 2-step transaction confirmation 
system built into it.  Your needs may not go this far, but such a design 
is possible.

If your needs are simple and the PICK server is on the same box as your 
drupal server, you can go straight into file sockets and talk directly 
to it from drupal.  My knowledge of PICK and its is about 6 years old, 
so my advice might be somewhat dated and there may be better options 

Good luck with this project,

More information about the drupal-devel mailing list