The online racing simulator
Searching in All forums
(5 results)
alistairuk
S2 licensed
it appears to be working now, thank you so much for your help.
alistairuk
S2 licensed
I hope this is what you mean;


[SIZE=2][COLOR=#2b91af]IS_ISI[/COLOR][/SIZE][SIZE=2] objConnect = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]IS_ISI[/COLOR][/SIZE][SIZE=2](0, [/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].strLFSPass, [/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].strAppName);
[/SIZE][SIZE=2][COLOR=#2b91af]Byte[/COLOR][/SIZE][SIZE=2][] data = PacketToData( objConnect );[/SIZE]
[SIZE=2]

[/SIZE]

When the debug pauses and I inspect the objects the objConnect has the correct values (as in structure above), is it possible ive defined the structure wrong?
alistairuk
S2 licensed
Ok, ive run it but I get a TypeMissMatch error at;

Marshal.StructureToPtr(SourceStruct, Ptr, false);
alistairuk
S2 licensed
Cheers, i'll give that a try.

No idea, I just copied and pasted it from Visual C# 2008 and it coloured it automatically.
C# Initial Packet Query
alistairuk
S2 licensed
Hi all,

I am attempting to connect to the InSim on an LFS server using c#.

So far I have:


[SIZE=2][COLOR=#2b91af]TcpClient[/COLOR][/SIZE][SIZE=2] objTCPC = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]TcpClient[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].strRemoteHost, [/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].intRemortPort);[/SIZE]
[SIZE=2][COLOR=#2b91af]NetworkStream[/COLOR][/SIZE][SIZE=2] objNS = objTCPC.GetStream();[/SIZE]
[SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][SIZE=2].WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"TCP Connected {0}:{1}"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].strRemoteHost, [/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].intRemortPort);[/SIZE]
[SIZE=2][COLOR=#008000]//Send Connection Packet[/COLOR][/SIZE]
[SIZE=2][COLOR=#2b91af]IS_ISI[/COLOR][/SIZE][SIZE=2] connect = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]IS_ISI[/COLOR][/SIZE][SIZE=2](0, [/SIZE][SIZE=2][COLOR=#a31515]"pass"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515]"appname"[/COLOR][/SIZE][SIZE=2]);[/SIZE]

Basically the problem is I havn't used Structures before and in order to send the IS_ISI structure I created I need to convert it to a Byte array.

Can anyone help me out? The structure is defined as per the InSim specifications file;

[SIZE=2][SIZE=2][COLOR=#008000]//InSim Init - Packet to initialise the InSim System [/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]struct[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]IS_ISI[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]byte[/COLOR][/SIZE][SIZE=2] Size = 44;[/SIZE]
[SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]byte[/COLOR][/SIZE][SIZE=2] Type = 1; [/SIZE][SIZE=2][COLOR=#008000]//ISP_ISI[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]byte[/COLOR][/SIZE][SIZE=2] ReqI = 1; [/SIZE][SIZE=2][COLOR=#008000]//Requests IS_VER packet[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]UInt16[/COLOR][/SIZE][SIZE=2] UDPPort = 0; [/SIZE][SIZE=2][COLOR=#008000]//Port for UDP Replies 0 - 65535[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]UInt16[/COLOR][/SIZE][SIZE=2] Flags = 32; [/SIZE][SIZE=2][COLOR=#008000]//Bit flags for options[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]byte[/COLOR][/SIZE][SIZE=2] Sp0 = 0;[/SIZE]
[SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]byte[/COLOR][/SIZE][SIZE=2] Prefix = System.Text.[/SIZE][SIZE=2][COLOR=#2b91af]Encoding[/COLOR][/SIZE][SIZE=2].ASCII.GetBytes([/SIZE][SIZE=2][COLOR=#a31515]"$"[/COLOR][/SIZE][SIZE=2])[0];[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]UInt16[/COLOR][/SIZE][SIZE=2] Interval;[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][SIZE=2][] Admin;[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][SIZE=2][] IName;[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2] IS_ISI([/SIZE][SIZE=2][COLOR=#2b91af]UInt16[/COLOR][/SIZE][SIZE=2] Interval, [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] Admin, [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] IName)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].Interval = Interval;[/SIZE]
[SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].Admin = Admin.ToCharArray();[/SIZE]
[SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].IName = IName.ToCharArray();[/SIZE]
[SIZE=2]}[/SIZE]

[SIZE=2]}[/SIZE]
[/SIZE]

FGED GREDG RDFGDR GSFDG