RE: "Byte Array"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm



> -----Original Message-----
> From: Ian Firla
> Sent: 14/12/04 17:52
> 
> On Tue, 2004-12-14 at 08:40 -0800, Richard Lynch wrote:
> > Ian Firla wrote:
> > >
> > > Just a follow-up to myself... I decided to try packet sniffing to
see
> > > what was going on and ettercap confirms that I'm sending out strings
> > > rather than data of the type stored in my array:
> > >
> > > 16:12:26  192.168.0.101:32779 --> 192.168.0.88:32896 | UDP |
> > >
> > >  0000: 3331                                     31
> > >
> > > That "31" should be an integer of only one byte, not two.
> > 
> > I suspect that PHP is converting your integers into strings at some
> point,
> > as you build the array...
> > 
> > *WHERE* it is doing that is difficult to say, without seeing more
code.

It's not at all difficult.  The definition of fwrite is:

  int fwrite (resource handle, string string [, int length])

So the second parameter is converted to a string as it passes in to fwrite.
This is not at all unexpected -- it's kind of the file(/stream/whatever)
analogue of echo or print.

To get what you really want -- i.e. a 1-byte binary representation of your
value -- you'll have to encode it as the appropriate character and then send
that.  Two possible ways to do that are with pack() and chr().

Cheers!

Mike

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux