void Start() { xmlDoc = new XmlDocument(); xmlDoc.Load(Application.streamingAssetsPath + "/ServerAddress.xml"); // hostAddress= XmlTool.ReadSingleNode(xmlDoc,"IPAddress"); port = int.Parse(XmlTool.ReadSingleNode(xmlDoc, "Port")); //ip = IPAddress.Parse(hostAddress); tlistener = new TcpListener(port); tlistener.Start(); thStartServer = new Thread(StartServer); thStartServer.Start();//启动该线程 clientList = new List <Client>(); }
void Start() { xmlDoc = new XmlDocument(); xmlDoc.Load(Application.streamingAssetsPath + "/ClientAddress.xml"); ipAddress = XmlTool.ReadSingleNode(xmlDoc, "IPAddress"); port = int.Parse(XmlTool.ReadSingleNode(xmlDoc, "Port")); IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(ipAddress), port); remoteDoc = new XmlDocument(); remoteDoc.Load(Application.streamingAssetsPath + "/ServerAddress.xml"); remoteIP = XmlTool.ReadSingleNode(remoteDoc, "IPAddress"); remortPort = int.Parse(XmlTool.ReadSingleNode(remoteDoc, "Port")); remotePoint = new IPEndPoint(IPAddress.Parse(remoteIP), remortPort); client = new TcpClient(endPoint); client.BeginConnect(remoteIP, remortPort, OnBeginConnect, client); }