发布网友 发布时间:2022-04-22 00:05
共3个回答
热心网友 时间:2023-11-30 12:24
public class Test10 {
public static void main(String[] args) throws Exception {
MyServer server = new MyServer(8080);
server.start();
Socket socket = new Socket("127.0.0.1", 8080);
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
bw.write("Hello, I Am Client!\n");
bw.flush();
String message = br.readLine();
System.out.println("Client Recieved: " + message);
br.close();
bw.close();
socket.close();
server.shutdown();
}
}
class MyServer extends Thread {
private boolean flag = false;
private Socket socket = null;
private ServerSocket server = null;
private BufferedReader br = null;
private BufferedWriter bw = null;
public MyServer(int port) throws IOException {
server = new ServerSocket(8080);
}
public void run() {
try {
flag = true;
socket = server.accept();
System.out.println("Server Started!");
br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
while (flag) {
String message = br.readLine();
if (message == null) {
continue;
}
System.out.println("Server Recieved: " + message);
bw.write("I am OK!\n");
bw.flush();
}
System.out.println("Server Closed!");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
}
}
if (bw != null) {
try {
bw.close();
} catch (IOException e) {
}
}
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
}
}
if (server != null) {
try {
server.close();
} catch (IOException e) {
}
}
}
}
public void shutdown() {
flag = false;
}
}
追问能把这个编码的原地址发给我吗
追答我自己写的,没有原地址
热心网友 时间:2023-11-30 12:25
以多项式形式输入系统前向通路传递函数和反馈回路传递函数计算系统开环增益判定型别根据控制系统劳斯稳定判据原理列出得到的任意阶次系统的劳斯表判定闭环系统稳定性若不稳定给出具有正实部极点的数目。
热心网友 时间:2023-11-30 12:25
你先搞清楚自己是哪种协议才可能编程。