socket 您的主机中的软件放弃了一个已建立的连接 300条连续发送数据,发送20到30条出现这种错误。
try
{
clientSocket.Connect(ipe);
while (true)
{
SocketPackage package = null;
lock (this)
{
if (queue.Count > 0)
{
package = queue.Dequeue();
}
}
if (package != null)
{
string sendStr = string.Format("DataUpload:{0}|{1}|{2}|{3}|{4}|{5}", package.user_ip, package.dst_domain, package.cur_dnsip, package.dst_ip, package.round_time, package.cernet_of);
Console.WriteLine(sendStr);
byte[] sendBytes = Encoding.ASCII.GetBytes(sendStr);
if (clientSocket.Connected)
{
clientSocket.Send(sendBytes);
Thread.Sleep(1000);
}
else
{
clientSocket.Connect(ipe);
clientSocket.Send(sendBytes);
}
}
}
}
catch (Exception e)
{
clientSocket.Shutdown(SocketShutdown.Both);
clientSocket.Close();
}