Home > php教程 > php手册 > php模拟飞鸽传输协议,代码实现向飞鸽发送消息

php模拟飞鸽传输协议,代码实现向飞鸽发送消息

WBOY
Release: 2016-06-13 09:34:53
Original
830 people have browsed it

飞鸽传书协议:
1:23149:riverlet:127.0.0.1:\x20:balabalabalabala
版本号:包编号:发送者姓名:发送者主机名:命令字:附加信息(消息内容)

<?<span>php

</span><span>define</span>("IPMSG_SENDMSG", 0x00000020);   <span>//</span><span> 0x00000020 命令字代表不同的命令</span><span>
#</span><span>define("IPMSG_SECRETOPT", 0x00000200);// 0x00000200 另一个命令字</span>
<span>define</span>("IPMSG_DEFAULTPORT", 2425);     <span>//</span><span>2425飞鸽传书端口</span>

<span>$sender</span> = 'XXX'<span>;
</span><span>$from</span> = '127.0.0.1'<span>;
</span><span>$msg_content</span> = 'XXXXXXXXXXXXXXXXXX'<span>;
</span><span>$send_to</span> = '192.168.10.110';  <span>//</span><span>对方主机IP</span>

<span>$fs</span> = <span>fsockopen</span>("udp://".<span>$send_to</span>, IPMSG_DEFAULTPORT); <span>//</span><span>用户数据报协议,一种无连接的传输层协议</span>
<span>fwrite</span>(<span>$fs</span>, "1:".<span>time</span>().":".<span>$sender</span>.":".<span>$from</span>.":".(IPMSG_SENDMSG).":".<span>$msg_content</span><span>);
</span><span>fclose</span>(<span>$fs</span>);
Copy after login

 

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template