views:

385

answers:

1

In a PHP script I am writing, I need to send a control+z character down a network socket I have previously created. I understand the ctrl+z character to be chr(26), so at the end of the string I am sending I have added a new line (\r\n) and then the chr(26) as follows:

$socket=fsockopen($host['host'],$host['port']);
fputs($socket, "I am a message\r\n" . chr(26));
fclose($socket);

Sadly, this isn't sending a Ctrl+Z, as I'd hoped it would.

Regards,

Jon

+1  A: 

It is probably being sent just fine. Add extra text after the ^Z to confirm.

The question is what do you want it to do when it gets there? Does the program you're communicating with handle a ^Z character how you'd expect it to?

I'm actually using PHP to programatically send SMS messages using a mobile phone in PDU mode. If I use the Text Mode and telnet in to the device, then it does process the Ctrl+z, although now that I've tried that in PDU mode, it doesn't seem to have worked. I'll check out sending text mode with PHP.
JonTheNiceGuy
I stopped using PDU mode, as it wasn't recognising the Ctrl+Z character. I moved to using Text mode, which did work most of the time. I then discovered a separate application called Gammu which provided the SMS interface I needed. Thanks for your help!
JonTheNiceGuy