在服务器端应该是output.println(cli_name);而不是output.println(ser_name);
解决方案 »
- jxl读excel文件出错,jxl.read.biff.BiffException: Unable to recognize OLE stream
- 急啊!!ftp服务器端对于超时的处理问题
- 内存问题
- Socket编程里,客户端怎么判断服务器程序没开启
- [新手问题]怎么得到JTextField中用户输入的字符串?
- java.io.IOException Server returned HTTP reponse code:405 for URL: http://www.xxxx.com/test
- socket问题?
- 请问怎样同时显示简体和繁体汉字?
- thinking in java source code 执行问题
- java 编译时的错误,因该很简单,可惜我不知道。(20)
- 网络文件传送问题
- 发现个字符串写入的问题!请帮忙!
没有编译错误,只是运行程序是没有响应,无法完成连接。建立连接时,首先在客户端请求连接,output.println(cli)发送客户端名到服务器端;然后服务器端接收客户端名,cli_name=input.readLine();并发送服务器名output.println(ser_name);
1。在客户端InetAddress addr = InetAddress.getByName(null);
Socket socket = new Socket(addr, TCPSingleUserServer.PORT);
从而达到建立与本机之间连接的目的。作相应修改后,程序正确运行。2。IO流:BufferedReader in =new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter out =new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true); 而我以前用的是: (错误!无法连接)
input=new DataInputStream(new BufferedInputStream (connection.getInputStream()));
output=new PrintStream(new BufferedOutputStream(connection.getOutputStream())); 使用这两种IO流又什么区别吗?
为什么下面这种会出错?
Socket socket = new Socket(InetAddress.getByName(null), PORT);或者
Socket socket = new Socket(InetAddress.getByName("localhost), PORT);都可以!问题在IO流方面,BufferedReader PrintWriter 和DataInputStream PrintStream使用起来有什么不同?在传送文本信息,以及传送文件时,应该使用何种IO流?vmware不会用,还要注册才能使用虚拟机吗?