【发布时间】:2017-09-28 14:56:42
【问题描述】:
我从控制台向服务器发送文本,服务器将其发送给我。
static void Main(string[] args)
{
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipserv = new IPEndPoint(IPAddress.Parse("46.174.49.48"), 46666);
client.Connect(ipserv);
byte[] data = Encoding.UTF8.GetBytes(Console.ReadLine());
client.Send(data);
client.Receive(data); //here is the error
Console.WriteLine(Encoding.UTF8.GetString(data));
Console.ReadLine();
}
错误:远程主机强行断开现有连接
服务器工作
【问题讨论】:
-
您需要发布可以重现问题的代码。您需要为服务器提供代码,或者如果服务器属于第三方,请提供您尝试与之通信的服务器的一些详细信息
标签: c# networking server udp client