I new to programming, can some one help i cant connect with LFS i use VB.Net
thank you for reading
regards Andy
thank you for reading
regards Andy
Dim Bytes(4) As Char
Dim NodeSecs(1) As Byte
Bytes(0) = "I"
Bytes(1) = "S"
Bytes(2) = "I"
Bytes(3) = ChrW(0)
NodeSecs(0) = 0
NodeSecs(1) = 0
Winsock1.Connect("127.0.1", 29999)
Winsock1.Send(Bytes)
Winsock1.RemotePort = (29998)
[COLOR=#000000][COLOR=#ff8000]//a small c++ example:
char v = 0;
InSimInit init_pack;
memset(&init_pack, 0, sizeof(InSimInit));
strcpy(init_pack.Id, "ISI" + v);
init_pack.Port = 12345;
init_pack.Flags = ISF_RACE_TRACKING|ISF_KEEP_ALIVE;
init_pack.NodeSecs = 0;
strcpy(init_pack.Admin,Text.c_str());
UDP1->SendBuffer((char*)&init_pack,1024,sizeof(InSimInit))[/COLOR][/COLOR]
Dim ISI(4) As Char
Dim admin(16) As Char
Dim port As String
Dim flags As Byte
Dim isiports(6) As Byte
Dim NodeSecs As Byte
Public Sub InSimInit()
ISI(0) = "I"
ISI(1) = "S"
ISI(2) = "I"
ISI(3) = ChrW(0)
NodeSecs = 0
flags = (16)
port = 12345
admin(0) = "T"
admin(1) = "E"
admin(2) = "S"
admin(3) = "T"
End Sub
Dim ISI(4) As Char
Dim admin(16) As Char
Dim port As String
Dim flags As Byte
Dim NodeSecs(2) As Byte
Dim ip As IPEndPoint
Dim sock As New UdpClient
Dim insim(13) As Byte
Public Sub InSimInit()
BitConverter.GetBytes(ISI(0) = "I").CopyTo(insim, 0)
BitConverter.GetBytes(ISI(1) = "S").CopyTo(insim, 1)
BitConverter.GetBytes(ISI(2) = "I").CopyTo(insim, 2)
BitConverter.GetBytes(ISI(3) = ChrW(0)).CopyTo(insim, 3)
BitConverter.GetBytes(NodeSecs(0) = 0).CopyTo(insim, 4)
BitConverter.GetBytes(flags = (16)).CopyTo(insim, 5)
BitConverter.GetBytes(port = 29999).CopyTo(insim, 6)
BitConverter.GetBytes(admin(0) = "T").CopyTo(insim, 7)
BitConverter.GetBytes(admin(1) = "E").CopyTo(insim, 8)
BitConverter.GetBytes(admin(2) = "S").CopyTo(insim, 9)
BitConverter.GetBytes(admin(3) = "T").CopyTo(insim, 10)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
InSimInit()
sock.Send(insim, 13)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
sock.Connect("127.0.0.1", 29999)
End Sub
Dim udp As New UdpClient
Dim ISI(4) As Char
Dim admin(16) As Char
Dim port As String
Dim flags As Byte
Dim NodeSecs As Byte
Dim ip As IPEndPoint
Dim Insim(13) As Byte
Public Sub InSimInit()
BitConverter.GetBytes(ISI(0) = "I").CopyTo(Insim, 0)
BitConverter.GetBytes(ISI(1) = "S").CopyTo(Insim, 1)
BitConverter.GetBytes(ISI(2) = "I").CopyTo(Insim, 2)
BitConverter.GetBytes(ISI(3) = ChrW(0)).CopyTo(Insim, 3)
BitConverter.GetBytes(port = 30001).CopyTo(Insim, 6)
BitConverter.GetBytes(flags = (16)).CopyTo(Insim, 5)
BitConverter.GetBytes(NodeSecs = 0).CopyTo(Insim, 4)
BitConverter.GetBytes(admin(0) = "T").CopyTo(Insim, 7)
BitConverter.GetBytes(admin(1) = "E").CopyTo(Insim, 8)
BitConverter.GetBytes(admin(2) = "S").CopyTo(Insim, 9)
BitConverter.GetBytes(admin(3) = "T").CopyTo(Insim, 10)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
InSimInit()
udp.Connect("127.0.0.1", 30001)
For i As Integer = 0 To 10
udp.Send(Insim, i)
'Stop
Next i
End Sub
BitConverter.GetBytes(ISI(0) = "I").CopyTo(Insim, 0)
UdpClient.ISI(0) = CByte("I")
... etc
UdpClient.ISI(3) = CByte(vbNULL)
[LEFT]BitConverter.GetBytes(ISI(0) = "I").CopyTo(Insim, 0)[/LEFT]
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)
};
Dim Insim(23) As Byte
BitConverter.GetBytes(ISI(3) = vbNullChar).CopyTo(Insim, 3)
Dim port As UInt16