當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。