Home > Article > Backend Development > PHP simulates Feige transmission protocol, and the code implements sending messages to Feige_PHP tutorial
Flying Pigeon Letter Protocol:
1:23149:riverlet:127.0.0.1:x20:balabalabalabala
Version number: Package number: Sender name: Sender host name: Command word: Append Information (message content)
<?<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>);