我想通过fsockopen成功连接UDP地址后收到回复消息。与RCON ModManager(游戏服务器)连接。
期待什么?
如果我使用Telnet:
Telnet 31.204.131.9 15502,我明白了:
ModManager Rcon v8.5
消化种子:iJrrQAkv
现在用PHP:
<?php
$_ip = '31.204.131.9' ;
$_port = '15502';
if (($socket = fsockopen ('udp://'.$_ip, $_port, $errno, $errstr, 30))) {
// till here it works, got connected
// Digest seed?
if(fwrite($socket, "GET / HTTP/1.1\r\n")) { // writing works }
echo fread($socket, 1024); // NOTHING
fclose($socket);
}
?>
你可以尝试.. IP和端口有效。 Thnx提前!!
答案 0 :(得分:0)
使用telnet时,使用tcp
协议,而不是udp
。尝试
<?php
$_ip = '31.204.131.9' ;
$_port = '15502';
if (($socket = fsockopen ($_ip, $_port, $errno, $errstr, 30))) {
// till here it works, got connected
// Digest seed?
if(fwrite($socket, "GET / HTTP/1.1\r\n")) { echo "writing works\n"; }
echo fread($socket, 1024); // NOTHING
fclose($socket);
}