| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3362 人关注过本帖
标题:[求助]java.net.ConnectException:Connection refused:connect
只看楼主 加入收藏
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
 问题点数:0 回复次数:1 
[求助]java.net.ConnectException:Connection refused:connect

编译通过了,但是在运行时出现下列错误,请高人指点:
java.net.ConnectException:Connection refused:connect


源文件:
import java.net.*;
import java.io.*;
class TcpTest
{
public static void main(String[] arg)
{
if(arg.length>0)
{ Procsure();}
else
Client();
}

public static void Procsure()
{
try
{
ServerSocket ss=new ServerSocket(6000);
Socket s=ss.accept();
OutputStream os=s.getOutputStream();
InputStream is=s.getInputStream();
os.write("hello!my name is fuqingjian".getBytes());
byte[] buf=new byte[100];
int len=is.read(buf);
System.out.println(new String(buf,0,len));
os.close();
is.close();
s.close();
ss.close();
}
catch(Exception e)
{
e.printStackTrace();
}

}
public static void Client()
{
try
{
Socket s=new Socket(InetAddress.getByName(null),6000);
OutputStream os=s.getOutputStream();
InputStream is=s.getInputStream();
byte[] buf=new byte[100];
int len=is.read(buf);
System.out.println(new String(buf,0,len));
os.write("hello,this is client!".getBytes());
os.close();
is.close();
s.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}

搜索更多相关主题的帖子: java Connection refused connect arg 
2007-04-16 09:45
fqj793
Rank: 1
等 级:新手上路
威 望:2
帖 子:228
专家分:0
注 册:2006-12-9
收藏
得分:0 
我自己找到原因了!对不起,打扰各位了!

知识改变命运!!!
2007-04-16 10:16
快速回复:[求助]java.net.ConnectException:Connection refused:connect
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014555 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved