本文整理汇总了Java中java.net.Inet4Address.getByName方法的典型用法代码示例。如果您正苦于以下问题:Java Inet4Address.getByName方法的具体用法?Java Inet4Address.getByName怎么用?Java Inet4Address.getByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.Inet4Address
的用法示例。
在下文中一共展示了Inet4Address.getByName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beginTrace
import java.net.Inet4Address; //导入方法依赖的package包/类
private void beginTrace(Jedis jedis, Method method) {
if (isTraceEnabled()) {
try {
InetAddress address = Inet4Address.getByName(jedis.getClient().getHost());
int port = jedis.getClient().getPort();
String serviceName = "redis-DB-" + jedis.getClient().getDB();
Beginning beginning = new Beginning();
beginning.setSpanName(serviceName);
beginning.setAddress(address);
beginning.setPort(port);
beginning.addAnnotation("execute.command", method.getName());
beginTrace(beginning);
} catch (Exception e) {
setClientSent();
}
}
}
示例2: beginTrace
import java.net.Inet4Address; //导入方法依赖的package包/类
public void beginTrace(String sql, String url) {
if (isTraceEnabled()) {
try {
String afterJDBC = url.substring(5); // jdbc:
String scheme = afterJDBC.substring(0, afterJDBC.indexOf(":"));
URLParser parser = parsers.get(scheme);
if (parser == null) {
throw new IllegalStateException("unknown db scheme: " + scheme);
}
DatabaseURL databaseUrl = parser.parse(url);
String serviceName = scheme + "-" + databaseUrl.getDataBase();
InetAddress address = Inet4Address.getByName(databaseUrl.getHost());
Beginning beginning = new Beginning();
beginning.setSpanName(serviceName);
beginning.setAddress(address);
beginning.setPort(databaseUrl.getPort());
beginning.addAnnotation("execute.sql", sql);
beginTrace(beginning);
} catch (Exception e) {
setClientSent();
}
}
}
示例3: pingButtonActionPerformed
import java.net.Inet4Address; //导入方法依赖的package包/类
private void pingButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pingButtonActionPerformed
String host = hostTF.getText();
try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
InetAddress adr = Inet4Address.getByName(host);
try{
adr.isReachable(3000);
JOptionPane.showMessageDialog(this, host+" is reachable, but it may not be the SpiNNaker!");
}catch(IOException notReachable){
JOptionPane.showMessageDialog(this, host+" is not reachable: "+notReachable.toString(), "Not reachable", JOptionPane.WARNING_MESSAGE);
}
} catch (UnknownHostException ex) {
JOptionPane.showMessageDialog(this, host+" is unknown host: "+ex.toString(), "Host not found", JOptionPane.WARNING_MESSAGE);
} finally {
setCursor(Cursor.getDefaultCursor());
}
}
示例4: pingButtonActionPerformed
import java.net.Inet4Address; //导入方法依赖的package包/类
private void pingButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pingButtonActionPerformed
String host = hostTF.getText();
try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
InetAddress adr = Inet4Address.getByName(host);
try {
adr.isReachable(3000);
JOptionPane.showMessageDialog(this, host + " is reachable. However it may not be the eDVS!");
} catch (IOException notReachable) {
JOptionPane.showMessageDialog(this, host + " is not reachable: " + notReachable.toString(), "Not reachable", JOptionPane.WARNING_MESSAGE);
}
} catch (UnknownHostException ex) {
JOptionPane.showMessageDialog(this, host + " is unknown host: " + ex.toString(), "Host not found", JOptionPane.WARNING_MESSAGE);
} finally {
setCursor(Cursor.getDefaultCursor());
}
}
示例5: createTcpTun_Client
import java.net.Inet4Address; //导入方法依赖的package包/类
public void createTcpTun_Client(String dstAddress,short dstPort) throws Exception{
Inet4Address serverAddress=(Inet4Address) Inet4Address.getByName(dstAddress);
TCPTun conn=new TCPTun(this,serverAddress,dstPort,local_mac,gateway_mac);
tcpManager.addConnection_Client(conn);
boolean success=false;
for(int i=0;i<6;i++){
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(conn.preDataReady){
success=true;
break;
}
}
if(success){
tcpManager.setDefaultTcpTun(conn);
}else {
tcpManager.removeTun(conn);
tcpManager.setDefaultTcpTun(null);
throw new Exception("创建隧道失败!");
}
}