本文整理匯總了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("創建隧道失敗!");
}
}