当前位置: 首页>>代码示例>>Java>>正文


Java Inet4Address.getByName方法代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:18,代码来源:JaRedisInterceptor.java

示例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();
        }
    }
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:24,代码来源:StatementTracer.java

示例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());
    }

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:19,代码来源:SpiNNaker_InterfaceFactory.java

示例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());
    }

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:19,代码来源:eDVS128_InterfaceFactory.java

示例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("创建隧道失败!");
	}
}
 
开发者ID:jonasxiao,项目名称:FinalSpeed,代码行数:25,代码来源:CapEnv.java


注:本文中的java.net.Inet4Address.getByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。