Ted*_*tel 1 java timeout tcp inputstream
我注意到,当我尝试阅读更多信息然后被发送到我的服务器时,Web浏览器将冻结.我看到我的套接字冻结,因为网络浏览器返回的信息较少,然后它正在尝试阅读.有没有办法在Currtly上设置一个时间我正在使用输入流
public String ReadLine()
{
String out;
out="";
// read in one line
try{
request = new StringBuffer(1000);
boolean f=true;
while(true)
{
int c=in.read();
if (c=='\r')
{
// next should be a \n
// Program freezed hear
c=in.read();
if (f==true)
return "";
break;
}
f=false;
out=out+(char)c;
request.append((char)c);
} // end while
} catch(IOException ec)
{
System.out.println(ec.getMessage());
}
System.out.println(request);
return out;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3552 次 |
| 最近记录: |