The online racing simulator
[php] Strange behaviour of LFS host
I run LFS nogfx host and then connect to it with a php script

> php\php.exe -q script.php


<?php 
include("insim_constants.inc.php");

set_time_limit (0);

$address '192.168.0.2';
$speakPort 29999;
$listenPort 30000;
$maxClients 1;

$sockIn socket_create(AF_INETSOCK_DGRAMSOL_UDP) or die("Couldn't create listen socket");
socket_bind($sockIn$address$listenPort) or die('Could not bind to address'); 

$sockOut socket_create(AF_INETSOCK_DGRAMSOL_UDP) or die("Couldn't create send socket");
socket_connect($sockOut$address$speakPort) or die('Could not connect to address'); 

$pack pack("CCCxSSxCSa16a16"44ISP_ISI1$listenPortISF_NLP361000"detail""detail");
socket_write($sockOut$packstrlen($pack));
print(
bin2hex(socket_read($sockIn20PHP_BINARY_READ)));

exit;
?>

Actually, the script makes a connection, receives ISP_VER and prints its contents to stdout, then closes. LFS should close the connection on timeout.

Strange thing is that in LFS window I see


InSim - UDP : detail (port 30000)
InSim - UDP : no slots available
InSim - UDP : no slots available
InSim timeout : detail

What causes those 2 "no slots" messages? I don't run the script twice.
The previous connection hasn't timed out yet, so when you are trying to connect LFS refuses it, as it thinks the slot is still being used (remember LFS only allows a single UDP connection at a time). In terms of why there are two, it's probably because two packets were received, or maybe the initial connection was made and then the IS_ISI received.

It takes LFS around two minutes to timeout a UDP connection.
Probably you didn't get it: I don't run the script again. I get these messages after the first and the only run of the host and the script.

0) No LFS is running for much time.
1) I start a new instance of LFS host
2) then I run a script just once. As soon as it recieves the ISP_VER packet, it ends.

And still there are those junk messages.
Ok, now I understand: it happens when my InSim app disconnects and LFS tries to send keepalive packets. LFS tries to connect to the same port, and there are no slots. That's what causes this message.

FGED GREDG RDFGDR GSFDG