Java??????server/client???????
???????????? ???????[ 2013/5/24 9:47:46 ] ????????
????Socket??????????????????£???????????·???????????????????????У?Socket?????????????????????????????Java?м?????
??????????????????????????????????????????????????????????????????????????????????綽?????????????????У???????????????????綽??С?
java????????
????????????????“????”?????????????????????????java.net????д??????ó???
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????£?
package com.javapp.ch11;
import java.io.*;
import java.net.*;
/**
* Description: ????“????”????????????????????
*/
public class EchoClientDemo {
// ???????????????
public static final int SERVERPORT = 990;
public static void main(String[] args) {
try {
// ??????????????
Socket s = new Socket("localhost"??SERVERPORT);
System.out.println("socket = " + s);
// ????????????????????
BufferedReader in = new BufferedReader(new InputStreamReader(s
.getInputStream()));
// ?????????????????μ????????
PrintWriter out = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(s.getOutputStream()))??true);
// ?????System.in????InputStreamReader???????BufferedReader??
BufferedReader stdin = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("Enter a string?? Enter BYE to exit! ");
while (true) {
// ?????????????????????????????????????????????????????????
out.println(stdin.readLine());
// ??????????????У????????????????????
String str = in.readLine();
// ?????????????????????????Enter????????????????????????????????
if (str == null) {
break;
}
System.out.println(str);
}
s.close();
} catch (IOException e) {
System.err.println("IOException" + e.getMessage());
}
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11