H3C 升级软件版本
2016-02-25 10:43
309 查看
下面把网络课设的源码拿出来晒晒,供大家参考
//检测线程
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.wst;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
/**
*
* @author Administrator
*/
public class TelnetThread implements Runnable {
private int port;
private String ip;
public void setPort(int port) {
this.port = port;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public String getIp() {
return ip;
}
public TelnetThread() {
ip = "127.0.0.1";
port = 8080;
}
public TelnetThread(String ip, int port) {
this.port = port;
this.ip = ip;
}
public void run() {
try {
Socket server = new Socket();
InetSocketAddress address = new InetSocketAddress(ip, port);
server.connect(address, 1000);
System.out.println(address.toString() + "可达");
} catch (IOException e) {
System.out.println("Thread: "+ip+":"+port+"不可达");
}
}
}
//检测主函数
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.wst;
import java.io.IOException;
import java.net.InetAddress;
/**
*
* @author Administrator
*/
public class TelnetTest {
public static void main(String[] args) {
try {
System.out.println("======InetAddress测试IP是否可达======");
InetAddress addressLocal = InetAddress.getLocalHost();
InetAddress addressRobot = InetAddress.getByName("210.45.251.3");
if (addressLocal.isReachable(3000)) {
System.out.println(addressLocal.toString() + "可达");
} else {
System.out.println(addressLocal.toString() + "不可达");
}
if (addressRobot.isReachable(3000)) {
System.out.println(addressRobot.toString() + "可达");
} else {
System.out.println(addressRobot.toString() + "不可达");
}
System.out.println("======Telnet测试IP是否可达======");
for (int i = 20; i < 8000; i++) {
Thread socketThread = new Thread(new TelnetThread("127.0.0.1",i));
socketThread.start();
}
} catch (IOException e) {
System.out.println("Main");
}
// Runtime run = Runtime.getRuntime();
//
// String msg = "";
// Process p = null;
// for (int i =20; i < 4000; i++) {
// StringBuffer command = new StringBuffer("telnet localhost ");
// p = run.exec((command.append(" ").append(i)).toString());
// BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
// while ((msg = in.readLine()) != null) {
// System.out.println("returnMsg: "+msg);
// }
//// System.out.println("End: "+(command.toString()));
// }
}
}
本文出自 “风停心止” 博客,请务必保留此出处http://wwssttt.blog.51cto.com/1289651/386931
//检测线程
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.wst;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
/**
*
* @author Administrator
*/
public class TelnetThread implements Runnable {
private int port;
private String ip;
public void setPort(int port) {
this.port = port;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public String getIp() {
return ip;
}
public TelnetThread() {
ip = "127.0.0.1";
port = 8080;
}
public TelnetThread(String ip, int port) {
this.port = port;
this.ip = ip;
}
public void run() {
try {
Socket server = new Socket();
InetSocketAddress address = new InetSocketAddress(ip, port);
server.connect(address, 1000);
System.out.println(address.toString() + "可达");
} catch (IOException e) {
System.out.println("Thread: "+ip+":"+port+"不可达");
}
}
}
//检测主函数
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.wst;
import java.io.IOException;
import java.net.InetAddress;
/**
*
* @author Administrator
*/
public class TelnetTest {
public static void main(String[] args) {
try {
System.out.println("======InetAddress测试IP是否可达======");
InetAddress addressLocal = InetAddress.getLocalHost();
InetAddress addressRobot = InetAddress.getByName("210.45.251.3");
if (addressLocal.isReachable(3000)) {
System.out.println(addressLocal.toString() + "可达");
} else {
System.out.println(addressLocal.toString() + "不可达");
}
if (addressRobot.isReachable(3000)) {
System.out.println(addressRobot.toString() + "可达");
} else {
System.out.println(addressRobot.toString() + "不可达");
}
System.out.println("======Telnet测试IP是否可达======");
for (int i = 20; i < 8000; i++) {
Thread socketThread = new Thread(new TelnetThread("127.0.0.1",i));
socketThread.start();
}
} catch (IOException e) {
System.out.println("Main");
}
// Runtime run = Runtime.getRuntime();
//
// String msg = "";
// Process p = null;
// for (int i =20; i < 4000; i++) {
// StringBuffer command = new StringBuffer("telnet localhost ");
// p = run.exec((command.append(" ").append(i)).toString());
// BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
// while ((msg = in.readLine()) != null) {
// System.out.println("returnMsg: "+msg);
// }
//// System.out.println("End: "+(command.toString()));
// }
}
}
本文出自 “风停心止” 博客,请务必保留此出处http://wwssttt.blog.51cto.com/1289651/386931
相关文章推荐
- GIS+=地理信息+云计算技术——[网络公开课]云GIS解决方案及应用案例
- js判断图片加载完成后获取图片实际宽高的方法
- JavaScript自动生成博文目录导航
- 安卓彩色二维码
- 拷贝一个用户下的所有表和数据到另外一个库
- Jsp中的pageContext对象
- 【Python环境】12道 Python面试题总结
- 细谈HTML5
- 微信 winwre 移动调试
- 修改远程桌面连接端口及修改端口号后如何连接!
- 转:Windows版本判断大全
- android开发中圆角图片的绘制
- 经营即修行(读书笔记)
- 初学者要了解的第三方库
- Java基础:Day07笔记内容 (面向对象)
- lua table 练习
- Android5 Zygote 与 SystemServer 启动流程分析
- mac 终端 常用命令
- 用户密码加密
- Delphi TListView刷新闪烁问题