A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 廖艺聪 中级黑马   /  2012-3-8 11:02  /  2170 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

ConnectException
应该如何处理? 网络编程那部分的内容

评分

参与人数 1技术分 +1 收起 理由
老罗 + 1

查看全部评分

2 个回复

倒序浏览
这个不能具体点吗?
Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the connection was refused remotely (e.g., no process is listening on the remote address/port).

这显然是出现了连接异常,当试图连接一个远程的地址和端口好号的套接字时,发生一个错误。典型有,这个连接被远程拒绝。例如:在远程的地址的端口号没有相对应的程序来处理。

回复 使用道具 举报
  1. public class TCPCustom {

  2.         public static void main(String[] args) throws Exception
  3.         {
  4.                 Socket s=new Socket("202.113.53.47",10002);
  5.                 OutputStream out=s.getOutputStream();
  6.                 out.write("tcp ge men lai le ".getBytes());
  7.                 s.close();
  8.                
  9.         }
  10. }
复制代码
这是我的代码,也出现这种错误怎么解决啊?
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马