public static void ConnectServer(XeQuaTram Xe) { try { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPHostEntry hostEntry = Dns.GetHostEntry(ModuleKhaiBaoConst.IPMayGiamSatMain); IPAddress[] addressList = hostEntry.AddressList; IPAddress[] array = addressList; IPAddress address = default(IPAddress); foreach (IPAddress iPAddress in array) { if (iPAddress.AddressFamily == AddressFamily.InterNetwork) { address = iPAddress; break; } } IPEndPoint remoteEP = new IPEndPoint(address, ModuleKhaiBaoConst.PortDuLieuChinhMain); socket.Connect(remoteEP); byte[] bytes = Encoding.ASCII.GetBytes(Xe.ToString()); socket.Send(bytes, bytes.Length, SocketFlags.None); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception ex2 = ex; ProjectData.ClearProjectError(); } CSDL.InsertXeQuaTram(ModuleKhaiBaoConst.StrConnectMain, Xe); try { CSDL.InsertXeQuaTram(ModuleKhaiBaoConst.StrConnectMain_mas, Xe); } catch (Exception ex3) { ProjectData.SetProjectError(ex3); Exception ex4 = ex3; ProjectData.ClearProjectError(); } }