SOCKET接收数据超时

thunderwolf 2009-04-26 10:36:30

try
{

senddata.WriteLine("entrybalance," + carbrand);
senddata.Flush();

//tcpClient2.ReceiveTimeout = 1000;
//tcpClient.ReceiveTimeout = 1000;

try
{

byte[] Data = new Byte[400];
Int32 bytes = ns.Read(Data, 0, Data.Length);
receiveData = Encoding.Default.GetString(Data, 0, bytes);
MessageBox.Show("2222");
}
catch (InterruptedException ie)
{
//在此调用再次写数据操作
}


double i_balance = Convert.ToDouble(receiveData);
if (i_balance <= 30) { c_i_ReasonType = 2; }
else { c_b_PermitPass = true; c_i_ReasonType = 0; }
c_isConnect = true;


}
catch
{
isConnect = false;//标记网络已经断开
c_b_PermitPass = false;
c_i_ReasonType = 3;
this.SetLabelText18(" ");

this.SetpictureBox7(global::EntryClient.Properties.Resources.datacenter_discon);//指示灯灭
if (s_dial.Equals("being"))
{
this.SetLabel5Color(System.Drawing.Color.Yellow);
this.SetLabelText5("连接中...");
}
else
{
this.SetLabel5Color(System.Drawing.Color.Red);
this.SetLabelText5("连接断开");
}
}


在这里面如何设置
...全文
205 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
q287551219 2009-04-26
  • 打赏
  • 举报
回复
终止本次循环啊!

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧