java socket
public void dotest()
{
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Socket socket = null;
String ip = "10.243.215.139";
//String ip = "127.0.0.1";
int port = 7101;
//int port = 8080;
for(;true;) {
try {
socket = new Socket(ip, port);
String string="socket连接ip:"+ ip+",端口:"+port+",成功:time:" + formatDate.format(new Date()) + " " + socket.isConnected();
System.out.println(string);
LogUtil.sokecttest(string);
socket.close();
Thread.sleep(10000);
} catch (Exception e) {
String s1="socket连接ip:"+ ip+",端口:"+port+",错误:" + formatDate.format(new Date()) + " " + e.toString();
System.out.println(s1);
LogUtil.sokecttest(s1);
}
}
}
下一篇: 【视频教程】JeeWx 微信开发入门视频