alistairuk
7th December 2007, 16:46
Hi all,
I am attempting to connect to the InSim on an LFS server using c#.
So far I have:
TcpClient objTCPC = newTcpClient(this.strRemoteHost, this.intRemortPort);
NetworkStream objNS = objTCPC.GetStream();
Console.WriteLine("TCP Connected {0}:{1}", this.strRemoteHost, this.intRemortPort);
//Send Connection Packet
IS_ISI connect = newIS_ISI(0, "pass", "appname");
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;
//InSim Init - Packet to initialise the InSim System
publicstructIS_ISI
{
staticbyte Size = 44;
staticbyte Type = 1; //ISP_ISI
staticbyte ReqI = 1; //Requests IS_VER packet
staticUInt16 UDPPort = 0; //Port for UDP Replies 0 - 65535
staticUInt16 Flags = 32; //Bit flags for options
staticbyte Sp0 = 0;
staticbyte Prefix = System.Text.Encoding.ASCII.GetBytes("$")[0];
publicUInt16 Interval;
publicchar[] Admin;
publicchar[] IName;
public IS_ISI(UInt16 Interval, string Admin, string IName)
{
this.Interval = Interval;
this.Admin = Admin.ToCharArray();
this.IName = IName.ToCharArray();
}
}
I am attempting to connect to the InSim on an LFS server using c#.
So far I have:
TcpClient objTCPC = newTcpClient(this.strRemoteHost, this.intRemortPort);
NetworkStream objNS = objTCPC.GetStream();
Console.WriteLine("TCP Connected {0}:{1}", this.strRemoteHost, this.intRemortPort);
//Send Connection Packet
IS_ISI connect = newIS_ISI(0, "pass", "appname");
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;
//InSim Init - Packet to initialise the InSim System
publicstructIS_ISI
{
staticbyte Size = 44;
staticbyte Type = 1; //ISP_ISI
staticbyte ReqI = 1; //Requests IS_VER packet
staticUInt16 UDPPort = 0; //Port for UDP Replies 0 - 65535
staticUInt16 Flags = 32; //Bit flags for options
staticbyte Sp0 = 0;
staticbyte Prefix = System.Text.Encoding.ASCII.GetBytes("$")[0];
publicUInt16 Interval;
publicchar[] Admin;
publicchar[] IName;
public IS_ISI(UInt16 Interval, string Admin, string IName)
{
this.Interval = Interval;
this.Admin = Admin.ToCharArray();
this.IName = IName.ToCharArray();
}
}