As I say I've never done any PHP/InSim before, but I had a look at the code and I think I figured it out. As you can see this is the original InSim initialisation packet from your existing code:
[COLOR=#000000][COLOR=#0000bb]
$packet [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]""[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000bb]$packet [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#dd0000]"ISI\0"[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000bb]$packet [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#0000bb]pack[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"S"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$localport[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000bb]$packet [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#0000bb]pack[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"c"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]38[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000bb]$packet [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#0000bb]pack[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"c"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000bb]$packet [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#0000bb]str_pad[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$adminPW[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]16[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]"\0"[/COLOR][COLOR=#007700]);
[/COLOR][/COLOR]
From looking at the old InSim.txt doc, which is used on the current 'stable' (0.5W) version of LFS, we can see the code above is the creation of this struct:
[FONT=Courier New, monospace][SIZE=2]struct InSimInit // UDP packet to initialise the InSim system[/SIZE][/FONT]
[FONT=Courier New, monospace][SIZE=2]{[/SIZE][/FONT]
[FONT=Courier New, monospace][SIZE=2] char Id [4]; // ISI + zero[/SIZE][/FONT]
[FONT=Courier New, monospace][SIZE=2] word Port; // Port for UDP replies from LFS (0...65535)[/SIZE][/FONT]
[FONT=Courier New, monospace][SIZE=2] byte Flags; // Bit flags for options - see below[/SIZE][/FONT]
[FONT=Courier New, monospace][SIZE=2] byte NodeSecs; // Number of seconds between NLP or MCI packets (0=none)[/SIZE][/FONT]
[FONT=Courier New, monospace][SIZE=2] char Admin [16]; // Admin password (required if set in LFS host options)[/SIZE][/FONT]
[FONT=Courier New, monospace][SIZE=2]};[/SIZE][/FONT]
So we need to rewrite this for the new version of LFS, so looking in the InSim.txt file for W17, we can see that old InSimInit struct has been changed to the snazzy new IS_ISI struct:
struct IS_ISI // InSim Init - packet to initialise the InSim system
{
byte Size; // 44
byte Type; // ISP_ISI
byte ReqI; // If non-zero LFS will send an IS_VER packet
byte Zero; // 0
word UDPPort; // Port for UDP replies from LFS (0 to 65535)
word Flags; // Bit flags for options (see below)
byte Sp0; // 0
byte Prefix; // Special host message prefix character
word Interval; // Time in ms between NLP or MCI (0 = none)
char Admin[16]; // Admin password (if set in LFS)
char IName[16]; // A short name for your program
};
So to rewrite this packet to meet the current specification I believe you would need to do this:
$packet = "";
$packet .= pack("c", 44); // Size of the packet
$packet .= pack("c", 1); // Packet ID, which is from the packet types enum
$packet .= pack("c", 1); // Set to 1 for LFS to send a version packet in response
$packet .= pack("c", 0); // Zero
$packet .= pack("S", 0); // The port for InSim to send back Udp packets, use zero for the same port as we are sending on
$packet .= pack("S", 1); // The bit flags, which allows you to set some options, check insim.txt for info
$packet .= pack("c", 0); // Sp0, which I think is spare or something...
$packet .= pack("c", "$"); // Message prefix character
$packet .= pack("S", 0); // Milliseconds to wait between sending NLP or MCI packets, if those are enabled in the bit flags
$packet .= str_pad("MyAdminPass", 16, "\0"); // The LFS admin password
$packet .= str_pad("Test Program", 16, "\0"); // A short name for your program
So that would create an equivalent packet for InSim V4. I hope that makes sense to you... I have not tested the above example, but I hope it points you on the right track. There are some very experienced PHP/InSim programmers on this forum, so I will leave it up to them to provide more detailed information. I'm a sad C# geek.
Edit: As I said before, I think it's going to be harder to learn InSim from the new version, as in my view it's actually more complicated, plus it will change again in the final patch X as Scawen is still tweaking it to perfection. I'd suggest messing about with the version of InSim V3 in 0.5W, which you original example should work on, and then move over to V4 for patch X when you are confident you understand how it all works together. I've been learning InSim over the last few weeks and I started with the old version for this very reason, now I 'get it' I'm about 75% through a whole C# InSim library I've been writing.