2024年6月7日发(作者:)
out = getWriter(socket);
String msg = null;
while ((msg = ne()) != null) {
n("msg:" + msg);
String res = "wwwwwwwwwwww哈哈w1241243123";
res = res + "rn";
(res);
();
}
} catch (IOException e) {
tackTrace();
} finally {
try {
if (socket != null)
();
} catch (IOException e) {
tackTrace();
}
try {
if (br != null)
();
} catch (IOException e) {
tackTrace();
}
try {
if (out != null)
();
} catch (IOException e) {
tackTrace();
}
}
}
}
package 64;
import edReader;
import edWriter;
import ption;
import treamReader;
import StreamWriter;
import ;
public class Client {
public static final String CHARCODE_UTF8 = "utf-8";
public static void main(String[] args) {
Socket socket = null;
int port = 8821;
BufferedReader br = null;
BufferedWriter out = null;
try {
socket = new Socket("localhost", port);
imeout(1000 * 60 * 5);
// 发送消息
String msg = "wwwwwwwwwwww哈哈w1241243123";
msg = msg + "rn";
out = new BufferedWriter(new OutputStreamWriter(
putStream(), CHARCODE_UTF8));
(msg);
();
// 接收服务器的反馈
br = new BufferedReader(new InputStreamReader(
utStream(), CHARCODE_UTF8));
String res = ne();
if (res != null) {
n("res:" + res);
}
} catch (IOException e) {
tackTrace();
} finally {
try {
if (socket != null)
();
} catch (IOException e) {
tackTrace();
}
try {
if (br != null)
();
} catch (IOException e) {
tackTrace();
}
if (out != null) {
try {
();
} catch (IOException e) {
tackTrace();
}
}
}
}
}


发布评论