I am wanting to send a packet to a server using PHP. I am trying to figure out how to conect with a predetermined IP, port and socket id. However, my code does not seem to be working properly, although no error is being shown.
function SendData($data){
$ip = "1.1.1.1";
$port = 31000;
$my_sock = '525'
$sock = fsockopen($ip, $port, $errnum, $errstr, $timeout);
if(!is_resource($sock)){
return false;
} else {
fputs($sock, $data);
return true;
}
SendData("@E");
SendData("DJ");
fclose($sock);
}
I am also considering doing this in Javascript, if possible. Whichever way works best.
Doesn’t your
SendDatafunction go into infinite recursion? Something like: