当前位置: 代码迷 >> Java相关 >> [求助]java.net.ConnectException:Connection refused:connect
  详细解决方案

[求助]java.net.ConnectException:Connection refused:connect

热度:1327   发布时间:2007-04-16 09:45:51.0
[求助]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  

----------------解决方案--------------------------------------------------------
我自己找到原因了!对不起,打扰各位了!
----------------解决方案--------------------------------------------------------
  相关解决方案