这是来自Microsoft套接字教程的示例http://msdn.microsoft.com/en-us/library/6y0e13d3.aspx
我有点困惑.第一个while(true)无限循环后跟第二个4行向下,但我们只使用一个break语句.在第二个while循环中使用break应该继续第一个while循环...不是吗? http://msdn.microsoft.com/en-us/library/6y0e13d3.aspx
while (true) {
Console.WriteLine("Waiting for a connection...");
// Program is suspended while waiting for an incoming connection.
Socket handler = listener.Accept();
data = null;
// An incoming connection needs to be processed.
while (true) {
bytes = new byte[1024];
int bytesRec = handler.Receive(bytes);
data += Encoding.ASCII.GetString(bytes,0,bytesRec);
if (data.IndexOf("<EOF>") > -1) {
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
157 次 |
| 最近记录: |