通信框架为networkcomms2.3.1
服务器端监听代码:
//从配置文件获取IP和端口 string strIP = System.Configuration.ConfigurationManager.AppSettings["IPAddress"]; int port = int.Parse(System.Configuration.ConfigurationManager.AppSettings["Port"]); IPEndPoint thePoint = new IPEndPoint(IPAddress.Parse(strIP), port); TCPConnection.StartListening(thePoint, false);
客户端连接代码为:
//从配置文件中获取IP IPAddress = System.Configuration.ConfigurationManager.AppSettings["IPAddress"]; //从配置文件中获取端口 Port = int.Parse(System.Configuration.ConfigurationManager.AppSettings["Port"]); //连接信息类 connInfo = new ConnectionInfo(IPAddress, Port); //与服务器端进行连接 newTcpConnection = TCPConnection.GetConnection(connInfo);
www.networkcomms.cn编辑
时间: 2024-11-01 13:43:46