关于Socket建立连接时,程序等待没有返回结果的问题 JDK1.4Socket s = new Socket();s.connect(new InetSocketAddress(host,port), timeout); //可以设置连接超时 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 搂主,你的代码根本有问题嘛!!inLine=in.readLine(); while( inLine!=null ) { System.out.println(inLine); }你这样只要inLine读进来不是null,岂不要死循环了?应该改成:while((inLine=in.readLine())!=null){ //....}吧。 sock client缺省还是阻塞的,即便你用socketchannel,所以你一定要显示的 SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); sc.connect(new InetSocketAddress(InetAddress.getByName(host), port)); int myPatience = 5; while ((!sc.finishConnect()) && (myPatience-- >0)) { System.out.println("I am waiting ..."); //sleep(400); } 对象序列化的问题 线程和socket的问题... 怎么把java程序嵌入在ie中 用Java编写本地搜索程序问题 呵呵,初学java,写了个扫雷练手 急:jxl读取指定excel文件,并为某列赋值。同时对一个sheet进行读写操作 能否把string型转成timestamp型的 java编辑器解决方案,大家来出谋划策啊!! 一个重载问题。为何结果是这样?? 高分求教关于jCheckBox[i]的问题 如何用rmi传送文件,请高手指点 sos:jdk下连接ms sqlserver for jdbc出错
inLine=in.readLine();
while( inLine!=null )
{
System.out.println(inLine);
}
你这样只要inLine读进来不是null,岂不要死循环了?应该改成:
while((inLine=in.readLine())!=null){
//....
}
吧。
sc.configureBlocking(false);
sc.connect(new InetSocketAddress(InetAddress.getByName(host), port)); int myPatience = 5;
while ((!sc.finishConnect()) && (myPatience-- >0)) {
System.out.println("I am waiting ...");
//sleep(400);
}