飛鴿傳書協議:
1:23149:riverlet:127.0.0.1:\x20:balabalabalabala
版本號:包編號:發送者姓名:發送者主機名:命令字:附加信息(消息內容)
<?php
define("IPMSG_SENDMSG", 0x00000020); // 0x00000020 命令字代表不同的命令
#define("IPMSG_SECRETOPT", 0x00000200);// 0x00000200 另一個命令字
define("IPMSG_DEFAULTPORT", 2425); //2425飛鴿傳書端口
$sender = 'XXX';
$from = '127.0.0.1';
$msg_content = 'XXXXXXXXXXXXXXXXXX';
$send_to = '192.168.10.110'; //對方主機IP
$fs = fsockopen("udp://".$send_to, IPMSG_DEFAULTPORT); //用戶數據報協議,一種無連接的傳輸層協議
fwrite($fs, "1:".time().":".$sender.":".$from.":".(IPMSG_SENDMSG).":".$msg_content);
fclose($fs);