本帖最后由 ゞ导火索゛ 于 2014-6-25 19:26 编辑
- package com.net;
- import java.net.InetAddress;
- import java.net.UnknownHostException;
- /*
- * 需求:通过客户端向浏览器端进行登陆请求,
- * 1,定义客户端
- * 2,定义键盘录入。通过主函数的参数进行
- * 3、将参数写出到服务器端
- * 4,接收服务器的响应
- */
- import java.io.*;
- import java.net.*;
- public class UserClient {
- public static void main(String[] args)
- {
- try
- {
- Socket client = new Socket(InetAddress.getByName("172.28.170.51"), 10000);
-
- BufferedReader bufr = new BufferedReader(new InputStreamReader(System.in));
-
- PrintWriter out = new PrintWriter(client.getOutputStream(), true);
-
- BufferedReader bufIn = new BufferedReader(new InputStreamReader(client.getInputStream()));
-
- for(int i=0; i<3; i++)
- {
- String line = bufr.readLine();
-
- out.println(line);
-
- String info = bufIn.readLine();
- System.out.println("info:" + info);
- if(info.contains("成功"))
- break;
-
- }
-
- client.close();
- bufr.close();
-
- } catch (UnknownHostException e) {
-
- e.printStackTrace();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- }
-
- }
复制代码 问题在UserServer的注释部分
|
|