如何在 PHP 中向套接字发送控制字符?

发布于 2024-07-08 02:09:43 字数 328 浏览 7 评论 0原文

在我正在编写的 PHP 脚本中,我需要向我之前创建的网络套接字发送一个 control+z 字符。 我知道 ctrl+z 字符是 chr(26),因此在我发送的字符串末尾添加了一个新行 (\r\n),然后添加了 chr(26),如下所示:

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

遗憾的是,这不是没有像我希望的那样发送 Ctrl+Z。

问候,

乔恩

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音盲 2024-07-15 02:09:43

可能发送得很好。 在 ^Z 之后添加额外文本进行确认。

问题是当它到达那里时你希望它做什么? 您正在通信的程序是否按照您期望的方式处理 ^Z 字符?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文