On 16/03/12 12:22, Mark Rogers wrote:
I have a device I need to talk to via UDP from within PHP (although it feels like my problem here is a Linux one not a PHP one as everything is being done at the socket level anyway).
I just tried this on PHP on Windows (albeit under VirtualBox on Linux) and it fails the same way. So it's not a Linux issue.
Anyone care to help me "convert" the PHP code to another language that I can test under Linux? It would be nice to see whether it's a PHP issue. (Can I do something similar from within bash?)
I have a suspicion that the Winsock DLLs under Windows are doing something that I'm not doing, but I have no idea what that might be.
The PHP code I'm struggling with is: // Create a socket $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); // Build the message $msg = hex2str('80 00 02 00 01 00 00 11 00 00 05 01'); // Send the message socket_sendto($socket, $msg, strlen($msg), 0, '192.168.251.132', '9600'); // Get the response - this line never returns socket_recvfrom($socket, &$buf, /*Max response length*/250, /*Flags*/0, &$ip, &$port);