Read the first byte of the rest of the buffer Start a loop (we'll call this packet parsing loop), using the following logic: whilst local counter + next packet size <= local buffer size We receive and append any data into the local temporary buffer Start a receive loop - wait until we get data or until we are told to quitĬopy any data in the global buffer into the local temporary buffer Send the ISI (InSim Initialisation) packetĪsk for the version to get sent (so that we can check that the thing we are connecting to is talking the same version of InSim)Ĭreate a global buffer and a way of recording the buffer size (only necessary in some languages) Make a connection to the given address and port Get data from user - address and port of client or server running InSim - usually localhost 29999 In pseudocode it looks something like this: Vague synchronous workflow of an InSim client If you're using a third party library then you won't be exposed to much of the "hardcore" networking as the library will be taking care of it for you. However, at the end of the day every InSim application, whether or not the programmer knows it, makes the same decisions and goes through the same steps to acheive a connection to LFS using InSim and to maintain the connection. It is more common to use TCP than UDP these days. UDP is faster, but you will get no notification if LFS goes away, and the packets may arrive in any order. TCP is "slower" but data from LFS is "guaranteed" to arrive whilst the connection is up, and will arrive at your program in a specific order. Just to get slightly more complicated you can talk to InSim in 2 different ways - over TCP and UDP.
Lfs s2 unexpected size packet how to#
All that InSim does, and can do, is inform a programmer how to get data out of LFS and how to put data back in.
Lfs s2 unexpected size packet code#
If you were using a compiled language you'd write the code, using whatever you want, and then you'd need to compile that code so that you can run it. For instance, you could write a PHP script, that understands how to talk to InSim, and then call it through the PHP command line interpreter. If you're using an interpreted language you can write the code, using whatever you want, and then run that code using the interpreter. What I'm trying to get at is that there's no correct way, in all cases, to create an InSim program. Similiarly if they were spanish you'd use a spanish style of teaching. If this person natively spoke another language, like English, you'd teach them in the way they expect to be taught in an english school. How you do this would depend on the person. You need to teach this "person" how to talk "french". Think of this programming language as a person. Take a programming language of your choice - any will do, as long as it can do some networking and there is some way for you to "pack" strings. Older versions maybe incompatible with the current version. There have been different versions (dialects) of InSim. To those who have written InSim applications before, I hope that if you have time, and the language you use is not covered, or that you can improve or post alternative examples or tutorials, that you could pop together a tutorial for your chosen language and/or library. This thread is designed to help you create your very first one, by providing a set of tutorials. Writing your first InSim application can be a bit daunting.