Reputation: 620
Im trying to send a 65 ascii char to a device Im reading from via php sockets. I need to reply to confirm the info has been received.
I have tried the following with no joy:
$ascii = ord("A"); // 65
socket_write($spawn, $ascii, strlen ($ascii)) or die("Could not write output\n");
is this correct?
Upvotes: 0
Views: 734
Reputation: 1
To send the character 'A' to the device, you should send it as a string rather than its ASCII value. Here's how you can do it:
$character = "A"; // The character you want to send socket_write($spawn, $character, strlen($character)) or die("Could not write output\n");
Upvotes: 0
Reputation: 780974
You're sending the string "65"
, not a single byte with that value. You can do:
socket_write($spawn, chr(65), 1) or die("Could not write output\n");
Upvotes: 1