?? 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 + -