Hmm.. OK. I found some info on creating the listening server with PHP, and all seems well there.
I dont think i am constucting the insim packets correctly here (i'm a n00b outside of PHP).
Running from an insim turorial i have this :-
<?php
$packet = "";
$packet .= "ISI\0";
$packet .= pack("S", $localport);
$packet .= pack("c", 38);
$packet .= pack("c", 1);
$packet .= str_pad($adminPW, 16, "\0");
// Send packet
fwrite($sender, $packet, strlen($packet));
?>
this connects, then based on a tutorial for INSIM i tried this.
<?php
echo "Connected! Requesting Version packet...\n\n";
// The version-request packet is a simple InSimPack with ID "VER" and Value 0.
$packet = "VER\0" . pack("i", intval(0));
// send packet
fwrite($sender, $packet, strlen($packet));
$packet = false;
// receive answer from LfS: a packet with ID "VER"
$timeout = time() + 2;
while (!$packet && time() <= $timeout) {
if ($packet = fread($receiver, 256)) {
break;
}
}
// check if really a version-packet arrived or something else we cant deal with at the moment
if (!$packet || substr($packet, 0, 3) != "VER") {
echo "No version package arrived, sorry :-(\n\n";
}
else {
// Parse version-package
$lfsV = trim(substr($packet, 4, 8)); // char
$lfsP = trim(substr($packet, 12, 6)); // char
$isv_raw = substr($packet, 18, 2); // word
if(strlen($isv_raw) < 2) {
$isv_raw = str_pad($isv_raw, 2, "\0");
}
$temp = unpack("S",$isv_raw);
$insimV = $temp[1];
// Show some version-information
echo "LfS Version-information:\n LfS Product: $lfsP\n"
. " LfS Version: $lfsV\n InSim Version: $insimV\n\n";
}
echo "Requesting InSimMulti-Package with Hostname now...\n\n";
// Now we request an InSimMulti-Package to get the LfS Hostname (if LfS is in multiplayer mode)
// To perform the request, we simply send an InSimPack with ID = "ISM" and Value = 0.
$packet = "ISM\0" . pack("i", intval(0));
// send packet
fwrite($sender, $packet, strlen($packet));
$packet = false;
// receive answer from LfS: a packet with ID "ISM"
$timeout = time() + 2;
while (!$packet && time() <= $timeout) {
if ($packet = fread($receiver, 256)) {
break;
}
}
// check if really a ISM-packet arrived or something else we cant deal with at the moment
if (!$packet || substr($packet, 0, 3) != "ISM") {
echo "No InSimMulti-package arrived, sorry :-(\n\n";
}
// Get LfS connection type: are we connected to a client (0) or a server (1)?
$type_raw = substr($packet, 4, 1);
$temp = unpack("c", $type_raw);
$type = $temp[1];
echo "LfS type: " . (($type == 0)?"Client":"Server") . "\n\n";
// Get LfS Hostname
$hostname = trim(substr($packet, 8, 32));
if(empty($hostname)) {
echo "Not in multiplayer mode\n\n";
}
else {
echo "Hostname: $hostname";
}
// if we are connected to a server, restart it
if($type == 1) {
echo "Now forcing server restart...\n\n";
// To inform the users, we will first send a MST(MessageTypePack)-packet to the server containing
// the information that the server will be restarted now.
// then we will force a server reinit, also using a MST.
$packet = "MST\0" . str_pad("^1SORRY, BUT THE SERVER WILL BE RESTARTED IN 3 SECONDS", 64, "\0");
fwrite($sender, $packet, strlen($packet));
$packet = "MST\0" . str_pad("/reinit", 64, "\0");
fwrite($sender, $packet, strlen($packet));
}
?>
then i disconnect
<?php
$packet = "ISC\0" . pack("i", intval(0));
fwrite($sender, $packet, strlen($packet));
fclose($sender);
fclose($receiver);
?>
This doesnt do anything exept connect and then disconnect?
If i can just figure out this basic bit.. I'm sure i can get it construct all the rest of what i need :-(
ty in advance to anyone that can help (btw i am writing for the new W17 patch),
Mikey