我一直本机调试:127.0.0.1 端口:1234
在初始连接中,服务器监听.客户端点连接服务器.服务器发现客户端连接,但好像这样:
private void AcceptCallback(IAsyncResult ar)
{
myReset.Set();
Socket listener=(Socket)ar.AsyncState;
handler=listener.EndAccept(ar);
getCommand="";
StateObject state=new StateObject();
state.workSocket=handler;
richTextBox1.AppendText("与客户建立连接\r\n");
try
{
byte[] byteData=System.Text.Encoding.UTF8.GetBytes("己经准备好,请通话!"+"\r\n<EOF>");
handler.BeginSend(byteData,0,byteData.Length,0,new AsyncCallback(SendCallback),handler);
//这句话:己经准备好,请通话!
//有时不能发送到客户端中,而要客户端再点一次连接或点二次才行
//请问是否有超时或什么其它原因存在?
//网络极其慢是否有影响?
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
Thread thread=new Thread(new ThreadStart(begReceive));
thread.Start();
}
在初始连接中,服务器监听.客户端点连接服务器.服务器发现客户端连接,但好像这样:
private void AcceptCallback(IAsyncResult ar)
{
myReset.Set();
Socket listener=(Socket)ar.AsyncState;
handler=listener.EndAccept(ar);
getCommand="";
StateObject state=new StateObject();
state.workSocket=handler;
richTextBox1.AppendText("与客户建立连接\r\n");
try
{
byte[] byteData=System.Text.Encoding.UTF8.GetBytes("己经准备好,请通话!"+"\r\n<EOF>");
handler.BeginSend(byteData,0,byteData.Length,0,new AsyncCallback(SendCallback),handler);
//这句话:己经准备好,请通话!
//有时不能发送到客户端中,而要客户端再点一次连接或点二次才行
//请问是否有超时或什么其它原因存在?
//网络极其慢是否有影响?
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
Thread thread=new Thread(new ThreadStart(begReceive));
thread.Start();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货