19,502
社区成员
发帖
与我相关
我的任务
分享
while (true)
{
try
{
client_socket.Connect(ipe);
}
catch
{
slabelshow.Text += "连接" + server_ip + "失败,请确认网络!\r\n";
}
slabelshow.Text += "正在发送MQ数据包....\r\n";
try
{
client_socket.Send(sendbuf, sendlen, 0);
slabelshow.Text += "MQ数据包发送完成,等待回执....\r\n";
}
catch
{
slabelshow.Text += "MQ数据包发送失败,请确认!....\r\n";
}
try
{
int bytes = client_socket.Receive(clientReceiveBytes, clientReceiveBytes.Length, 0);
clientReceiveStr = Encoding.ASCII.GetString(clientReceiveBytes, 0, bytes);
Console.WriteLine("\nServer Said:{0}", clientReceiveStr);
//在此进行判断接收的数据是否为回执数据包
}
catch
{
}
client_socket.Shutdown(SocketShutdown.Both);
client_socket.Close();
}
}