Hello. I am that kind of guy that has to try everything. I usually solve my problems but in this case I need a push in the right direction.
From insim.txt
So. How hard can it be to try this in java? Well. I quickly wrote a sampleprogram but realized that UDP is something I'm not too familiar with.
Especially not in Java. illepall
See that string? "ISI00000password".. Am I totally out in the bush here or do I have something going with this code?
From insim.txt
struct InSimInit // UDP packet to initialise the InSim system
{
char Id [4]; // ISI + zero
word Port; // Port for UDP replies from LFS (0...65535)
byte Flags; // Bit flags for options - see below
byte NodeSecs; // Number of seconds between NLP or MCI packets (0=none)
char Admin [16]; // Admin password (required if set in LFS host options)
};
So. How hard can it be to try this in java? Well. I quickly wrote a sampleprogram but realized that UDP is something I'm not too familiar with.
Especially not in Java. illepall
package lfs.udp;
import java.io.*;
import java.net.*;
public class UDPSend
{
protected static final int TIMEOUT = 5000;
public static void main(String args[])
{
try
{
String host = "localhost";
InetAddress address = InetAddress.getByName(host);
byte[] message = "ISI00000password".getBytes();
DatagramPacket packet = new DatagramPacket(message, message.length, address, 15567);
DatagramSocket dsocket = new DatagramSocket();
dsocket.setSoTimeout(TIMEOUT);
dsocket.send(packet);
// Wait for a answer.. Hopefully.
byte[] buffer = new byte[2048];
DatagramPacket answerpacket = new DatagramPacket(buffer, buffer.length);
dsocket.receive(answerpacket);
String msg = new String(buffer, 0, answerpacket.getLength());
System.out.println("recevied: "+msg);
dsocket.close();
}
catch (Exception e)
{
System.err.println(e);
}
}
}
See that string? "ISI00000password".. Am I totally out in the bush here or do I have something going with this code?