Ian Firla wrote:
> I thought of that too and have since expanded my debugging. The types
> are correct when passed to fwrite. They come out the other end as
> strings:
>
> 16:39:54 SENT     'K' of type string
> 16:39:54 SENT     '0' of type integer
> 16:39:54 SENT     '0' of type integer
> 16:39:54 SENT     '65' of type integer
> 16:39:54 SENT     '31' of type integer
>
> 15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |
>
>  0000: 4b                                       K
>
>
> 15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |
>
>
>  0000: 30                                       0
>
>
> 15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |
>
>  0000: 30                                       0
>
>
> 15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |
>
>  0000: 3635                                     65
>
>
> 15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |
>
>  0000: 3331                                           31
>
> As you can see, the last two elements "65" and "31" have arrived as
> strings of two bytes rather than integers of one.

Damn.

Okay, maybe maybe maybe try putting your binary data into a temp file, and
then sending that file out.

It won't be fast, but it might suffice for what you need.

That's assuming fwrite() to a file will output binary data...

Another option would be to convert to the string that would match the
binary data you want...

if (is_int($msg_to_send)){
  fwrite($fp, chr($msg_to_send));
}
else{
  fwrite($fp, $msg_to_send);
}

This would be faster, and probably cleaner than the temp file, actually.

NOTE: is_int is faster than gettype() == 'integer' and the manual states
that they don't guarantee that 'integer' won't change some day.  Use
is_int.

-- 
Like Music?
http://l-i-e.com/artists.htm

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

Reply via email to