The online racing simulator
Insim with PHP on Dedi z28
Hi to all
Please help me
I want to code a insim php to my LFSDediz28 server
I read a lot of article but i couldnt find a help for me
The connect with php is ok
but if i send e message
Answer the server with
Insim: first byte of paket does not match
Please help me with pakets
An example was cool for me
Hi an alle
Ich möchte für meinen LFSDediz28 server eine insim Programmieren
Das verbinden mittels PHP klappt
Aber wenn ich ein paket sende kommt es zum fehler
Insim: first byte of paket does not match
Ich komme mit dem insim.txt net klar
hab das php beispiel genommen ,aber da bekomme ich keine verbindung
Es wäre schön wenn jemand mal ein beispiel paket oder php schript hat
danke
Post your code.
Here it is but is not my code!!! its is from other user
He can connect
He can receive result is : Resource id #68
but couldnt write error :Insim : first byte in Packet does not match size
Please helpme
Can you send me a php example for Insim in php for Insim version 4
It is a LFS Z28 Server
Thanks
<?php
// CONFIG START
$insimIP = '192.168.128.119'; // Your InSim-IP Here
$insimPort = 29999; // Your InSim-Port
$adminPW = 'password'; // Your Admin-Password
// CONFIG END
// create sender filestream
$errno = 0; $errstr = "";
$sender = @fsockopen("udp://$insimIP", $insimPort, &$errno, &$errstr, 3);
if (!$sender) {
die("Error:\nCould not connect to $insimIP:$insimPort\n"
. "Error Number: $errno\nError Description: $errstr");
}
// create receiver filestream
$localport = 63392;
$receiver = false;
while ($localport <= 65535) {
$receiver = @stream_socket_server("udp://192.168.128.119:$localport", $errno, $errstr, STREAM_SERVER_BIND);
if (is_resource($receiver)) {
break;
}
$localport++;
$receiver = false;
}
if ($receiver === false) {
die("Error:\nCould not bind to $localport\nError Number: $errno\nError Description: $errstr");
}
// Make the receiver stream nonblocking to be able to apply timeouts
stream_set_blocking($receiver, 0);
/*
VARIABLES AFTER HERE:
$sender : sender filestream
$receiver : receiver filestream
$localport : port of receiver filestream
+ config variables
*/
// We will now have to send an ISI (InSimInit)-packet to InSim to make it accept our requests.
// Prepare packet
$packet = "";
$packet .= "ISI\1"; // Packet-ID
$packet .= pack("S", $localport); // response port
$packet .= pack("c", 2+4+32); // Connection Flags - see InSim.txt
$packet .= pack("c", 1); // NodeSecs - time between packages
if (strlen($adminPW) > 16) {
$adminPW = substr($adminPW, 0, 16); // Cut down adminpw if too long
}
$packet .= str_pad($adminPW, 16, "\0"); // Admin-Password if set in LFS host options
// Send packet
fwrite($sender, $packet, strlen($packet)); // Third parameter to make PHP ignore magic_quotes-setting
$content = $receiver;
?>
Thanks but...
But i want lear about insim and this is a big package that is difficult to learn
A Simple Scriprt to connect and create a packet and send it
A simple Script to receive data from insim
Thats all what i want
Ok but really belive me. I started on PHPLFS and I learned to OOP with it. Analyze code very strictly and you'll be awesome PHP InSim programmer.
How have I never seen that project before?
Quote from Kalli1971 :But i want lear about insim and this is a big package that is difficult to learn
A Simple Scriprt to connect and create a packet and send it
A simple Script to receive data from insim
Thats all what i want

There is a simple PHP example in the manual which you can look at.

http://en.lfsmanual.net/wiki/InSim_examples

FGED GREDG RDFGDR GSFDG