I'm trying to send some binary data to a UDP server using PHP.  The examples
I've been able to find show sending binary data over TCP, or they show
sending text over UDP.

I'm constructing the messages using the below:

  $text_msg = "Hello, World\r\n";
  $binary_msg = chr(0x01).chr(0x02).chr(0x00).chr(0xAD);
  $binary_msg_size = 4;

I've tried a couple methods of sending the data:

  $fp = fsockopen("udp://" . $host,$port,....);
  fwrite($fp,$binary_msg,$binary_msg_size);

and

  $sock = socket_create(AF_INET,SOCK_DGRAM,SOL_UDP);
  socket_sendto($sock,$binary_msg,$binary_msg_size,0,$host,$port);

In either case, a UDP packet is sent, but with a zero data size.  If I
instead send the $text_msg, it works as expected.  For some reason sending
the binary data doesn't work.

Does anyone have insight into how to send binary data over UDP using PHP?

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

Reply via email to