public void insimConnectTCP(string host, int port, string adminPassword, string mode, string nameApp, bool isLocal) { int nbTry = 0; int maxTry = 40; tc = new TcpConnection.Connection(host, port); retryConnect: Console.Write("Connecting"); try { tc.Connect(); } catch { if (nbTry++ > maxTry) { Console.WriteLine(""); throw; } else { System.Threading.Thread.Sleep(1000); Console.Write("."); goto retryConnect; } } Console.WriteLine(""); Console.WriteLine("Connection OK"); byte[] inSimInit = InSim.Encoder.ISI(adminPassword, 0, 0, nameApp, isLocal); try { this.Send(inSimInit, inSimInit.Length); } catch { throw; } byte[] recvPacket; recvPacket = this.Receive(); InSim.Decoder.VER ver = new InSim.Decoder.VER(recvPacket); this.connected = true; this.Product = ver.Product; this.Version = ver.Version; this.InSimVersion = ver.InSimVersion; }
public void insimConnectUDP(string host, int port, string adminPassword, string mode,string nameApp,bool isLocal ) { int nbTry = 0; int maxTry = 40; Console.Write("Connecting"); retryConnect: try { uc = new System.Net.Sockets.UdpClient(host, port); } catch { throw; } #if MONO int localport = 0; //for mono #else int localport = ((System.Net.IPEndPoint)uc.Client.LocalEndPoint).Port;//for .NET #endif byte[] inSimInit = InSim.Encoder.ISI(adminPassword, localport, 0, nameApp,isLocal ); try { this.Send(inSimInit, inSimInit.Length); } catch { throw; } //request version Not Need in insim 4, because ISI send This // byte[] verreq = InSim.Encoder.VER(); // this.Send(verreq, verreq.Length); //retr version info byte[] recvPacket; try { recvPacket = this.Receive(); } catch { if (nbTry++ > maxTry) { Console.WriteLine(""); throw; } else { System.Threading.Thread.Sleep(1000); Console.Write("."); goto retryConnect; } } Console.WriteLine(""); Console.WriteLine("Connection OK"); InSim.Decoder.VER ver = new InSim.Decoder.VER(recvPacket); this.connected = true; this.Product = ver.Product; this.Version = ver.Version; this.InSimVersion = ver.InSimVersion; }
public void insimConnectTCP(string host, int port, string adminPassword, string mode, string nameApp, bool isLocal ) { int nbTry = 0; int maxTry = 40; tc = new TcpConnection.Connection(host, port); retryConnect: Console.Write("Connecting"); try { tc.Connect(); } catch { if (nbTry++ > maxTry) { Console.WriteLine(""); throw; } else { System.Threading.Thread.Sleep(1000); Console.Write("."); goto retryConnect; } } Console.WriteLine(""); Console.WriteLine("Connection OK"); byte[] inSimInit = InSim.Encoder.ISI(adminPassword, 0, 0, nameApp,isLocal); try { this.Send(inSimInit, inSimInit.Length); } catch { throw; } byte[] recvPacket; recvPacket = this.Receive(); InSim.Decoder.VER ver = new InSim.Decoder.VER(recvPacket); this.connected = true; this.Product = ver.Product; this.Version = ver.Version; this.InSimVersion = ver.InSimVersion; }
public void insimConnectUDP(string host, int port, string adminPassword, string mode, string nameApp, bool isLocal) { int nbTry = 0; int maxTry = 40; Console.Write("Connecting"); retryConnect: try { uc = new System.Net.Sockets.UdpClient(host, port); } catch { throw; } #if MONO int localport = 0; //for mono #else int localport = ((System.Net.IPEndPoint)uc.Client.LocalEndPoint).Port; //for .NET #endif byte[] inSimInit = InSim.Encoder.ISI(adminPassword, localport, 0, nameApp, isLocal); try { this.Send(inSimInit, inSimInit.Length); } catch { throw; } //request version Not Need in insim 4, because ISI send This // byte[] verreq = InSim.Encoder.VER(); // this.Send(verreq, verreq.Length); //retr version info byte[] recvPacket; try { recvPacket = this.Receive(); } catch { if (nbTry++ > maxTry) { Console.WriteLine(""); throw; } else { System.Threading.Thread.Sleep(1000); Console.Write("."); goto retryConnect; } } Console.WriteLine(""); Console.WriteLine("Connection OK"); InSim.Decoder.VER ver = new InSim.Decoder.VER(recvPacket); this.connected = true; this.Product = ver.Product; this.Version = ver.Version; this.InSimVersion = ver.InSimVersion; }