📄 clientteller.java
字号:
package com.ideas.communicate;
import java.net.*;
import java.io.*;
/**
* 与被监控主机之间的通信
*/
public class ClientTeller {
public static void send(String destIP, int port, String content) {
Socket clientsock = null;
try {
InetAddress target = InetAddress.getByName(destIP);
clientsock = new Socket(target, port);
}
catch (Exception e) {
System.err.println("自动处理程序不能连接主机:" +
destIP + "/" +
port);
return;
}
try {
DataOutputStream dos = new DataOutputStream(clientsock.getOutputStream());
dos.write(content.getBytes());
dos.close();
clientsock.close();
}
catch (Exception e) {
System.err.println("报警消息发送失败");
e.printStackTrace();
}
}
public static void main(String args[]) {
ClientTeller.send("192.168.2.117", 15001, "fs./home.ritem@");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -