Connection timeout??

opteva 2009-10-27 07:42:46
我用Socket编程写了个小程序 
    public static void main(String[] args){
System.out.println( "This is client" );
byte[] buf = new byte[100];
try {
Socket s = new Socket("xxx.xxx.xxx.xxx",8899);
OutputStream os = s.getOutputStream( );
InputStream is = s.getInputStream( );
String sndStr;
String Deviceno;
String DDate;
String fileName;

Deviceno=getDevice();
DDate=getDate();
sndStr= Deviceno+" "+DDate+".J";
fileName="c:\\wsap\\data\\"+DDate+".J";

os.write( sndStr.getBytes( ) );
    ........
} catch(Exception ex)
{
ex.printStackTrace( );
System.out.println("err... client exit");
System.exit(0);
}

在catch之后printStackTrace()提示 ....Connection Timeout.......等一些信息,之后err退出
    是在建立Socket时出错了吗???网是通的,什么原因呀???


...全文
166 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
loveofmylife 2009-10-27
  • 打赏
  • 举报
回复
tcp传输超时,网络应该是阻塞了
临远 2009-10-27
  • 打赏
  • 举报
回复
连接超时,服务器没有响应,可能因为网络问题。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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