org.apache.tomcat.jni.Address类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中org.apache.tomcat.jni.Address类的一些代码示例,展示了Address类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address类的具体详情如下:
包路径:org.apache.tomcat.jni.Address
类名称:Address

Address介绍

[英]Address
[中]住址

代码示例

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

/**
 * Port in use.
 */
@Override
public int getLocalPort() {
  long s = serverSock;
  if (s == 0) {
    return -1;
  } else {
    long sa;
    try {
      sa = Address.get(Socket.APR_LOCAL, s);
      Sockaddr addr = Address.getInfo(sa);
      return addr.port;
    } catch (Exception e) {
      return -1;
    }
  }
}

代码示例来源:origin: apache/cloudstack

/**
 * Connect this socket wrapper to remote server and start main loop on
 * AprSocketSource stdout link, to watch for incoming data, and
 * AprSocketSink stdin link, to pull for outgoing data.
 */
@Override
public void connect(InetSocketAddress address) throws IOException {
  try {
    inetAddress = Address.info(address.getHostName(), Socket.APR_UNSPEC, address.getPort(), 0, pool);
    socket = Socket.create(Address.getInfo(inetAddress).family, Socket.SOCK_STREAM, Socket.APR_PROTO_TCP, pool);
  } catch (Exception e) {
    throw new IOException("[" + this + "] ERROR: Cannot create socket for \"" + address + "\".", e);
  }
  int ret = Socket.connect(socket, inetAddress);
  if (ret != 0)
    throw new IOException("[" + this + "] ERROR: Cannot connect to remote host \"" + address + "\": " + Error.strerror(ret));
  source.setSocket(socket);
  sink.setSocket(socket);
  // Start polling for data to send to remote sever
  runMainLoop(IN, STDIN, true, true);
  // Push incoming data from server to handlers
  runMainLoop(OUT, STDOUT, false, false);
}

代码示例来源:origin: codefollower/Tomcat-Research

public String getRemoteHostname() throws IOException {
  if (socket != 0 && context.running) {
    try {
      long sa = Address.get(Socket.APR_REMOTE, socket);
      String remoteHost = Address.getnameinfo(sa, 0);
      if (remoteHost == null) {
        remoteHost = Address.getip(sa);
      }
      return remoteHost;
    } catch (Exception ex) {
      throw new IOException(ex);
    }
  }
  throw new IOException("Socket closed");
}

代码示例来源:origin: codefollower/Tomcat-Research

public String getLocalAddress() throws IOException {
  if (socket != 0 && context.running) {
    try {
      long sa = Address.get(Socket.APR_LOCAL, socket);
      return Address.getip(sa);
    } catch (Exception ex) {
      throw new IOException(ex);
    }
  }
  throw new IOException("Socket closed");
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

long sa = Address.get(Socket.APR_REMOTE, socketRef);
  remoteAddr = Address.getip(sa);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  localName = Address.getnameinfo(sa, 0);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_REMOTE, socketRef);
  remoteHost = Address.getnameinfo(sa, 0);
  if (remoteHost == null) {
    remoteHost = Address.getip(sa);
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  localAddr = Address.getip(sa);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_REMOTE, socketRef);
  Sockaddr addr = Address.getInfo(sa);
  remotePort = addr.port;
} catch (Exception e) {
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  Sockaddr addr = Address.getInfo(sa);
  localPort = addr.port;
} catch (Exception e) {

代码示例来源:origin: codefollower/Tomcat-Research

public String getLocalHostname() throws IOException {
  if (socket != 0 && context.running) {
    try {
      long sa = Address.get(Socket.APR_LOCAL, socket);
      return Address.getnameinfo(sa, 0);
    } catch (Exception ex) {
      throw new IOException(ex);
    }
  }
  throw new IOException("Socket closed");
}

代码示例来源:origin: jboss.web/jbossweb

long socket = Socket.create(serverAddressFamily, Socket.SOCK_STREAM,
    Socket.APR_PROTO_TCP, rootPool);
long inetAddress = Address.info(addressStr, serverAddressFamily,
    listsock[i].port, 0, rootPool);
if (Socket.connect(socket, inetAddress) != 0) {

代码示例来源:origin: stackoverflow.com

String jsonString = "{\n"
  + "  \"customerName\":\"John\",\n"
  + "  \"emailAddress\":\"john@fake.com\",\n"
  + "  \"address1\":\"Fake St.\",\n"
  + "  \"age\": 20,\n"
  + "  \"height\": 5\n"
  + "}";
Gson gson = new Gson();
Address address = gson.fromJson(jsonString, Address.class);
String name = (String)address.get("customerName"); // John
int age = (int)address.get("age"); // 5

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

long sa = Address.get(Socket.APR_REMOTE, socketRef);
  remoteAddr = Address.getip(sa);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  localName = Address.getnameinfo(sa, 0);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_REMOTE, socketRef);
  remoteHost = Address.getnameinfo(sa, 0);
  if (remoteHost == null) {
    remoteHost = Address.getip(sa);
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  localAddr = Address.getip(sa);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_REMOTE, socketRef);
  Sockaddr addr = Address.getInfo(sa);
  remotePort = addr.port;
} catch (Exception e) {
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  Sockaddr addr = Address.getInfo(sa);
  localPort = addr.port;
} catch (Exception e) {

代码示例来源:origin: codefollower/Tomcat-Research

public String getRemoteAddress() throws IOException {
  if (socket != 0 && context.running) {
    try {
      long sa = Address.get(Socket.APR_REMOTE, socket);
      return Address.getip(sa);
    } catch (Exception ex) {
      throw new IOException(ex);
    }
  }
  throw new IOException("Socket closed");
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
protected void populateLocalName() {
  if (closed) {
    return;
  }
  try {
    long socket = getSocket().longValue();
    long sa = Address.get(Socket.APR_LOCAL, socket);
    localName =Address.getnameinfo(sa, 0);
  } catch (Exception e) {
    log.warn(sm.getString("endpoint.warn.noLocalName"), e);
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

Address.info(null, family, port, 0, serverSockPool);

代码示例来源:origin: stackoverflow.com

String cityName = (mAddresses != null) ? mAddresses.get(0)
    .getLocality() : TimeZone.getDefault().getID();
String countryName = (mAddresses != null) ? mAddresses.get(0)
    .getCountryName() : Locale.getDefault().getDisplayCountry()
    .toString();

代码示例来源:origin: org.apache.coyote/com.springsource.org.apache.coyote

long sa = Address.get(Socket.APR_REMOTE, socketRef);
  remoteAddr = Address.getip(sa);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  localName = Address.getnameinfo(sa, 0);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_REMOTE, socketRef);
  remoteHost = Address.getnameinfo(sa, 0);
  if (remoteHost == null) {
    remoteHost = Address.getip(sa);
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  localAddr = Address.getip(sa);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_REMOTE, socketRef);
  Sockaddr addr = Address.getInfo(sa);
  remotePort = addr.port;
} catch (Exception e) {
  long sa = Address.get(Socket.APR_LOCAL, socketRef);
  Sockaddr addr = Address.getInfo(sa);
  localPort = addr.port;
} catch (Exception e) {

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Port in use.
 */
@Override
public int getLocalPort() {
  long s = serverSock;
  if (s == 0) {
    return -1;
  } else {
    long sa;
    try {
      sa = Address.get(Socket.APR_LOCAL, s);
      Sockaddr addr = Address.getInfo(sa);
      return addr.port;
    } catch (Exception e) {
      return -1;
    }
  }
}

代码示例来源:origin: org.apache.coyote.springsource/com.springsource.org.apache.coyote.springsource

long inetAddress = Address.info(addressStr, family,
    port, 0, rootPool);
serverSock = Socket.create(Address.getInfo(inetAddress).family,
    Socket.SOCK_STREAM,
    Socket.APR_PROTO_TCP, rootPool);

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
protected void populateRemoteHost() {
  if (closed) {
    return;
  }
  try {
    long socket = getSocket().longValue();
    long sa = Address.get(Socket.APR_REMOTE, socket);
    remoteHost = Address.getnameinfo(sa, 0);
    if (remoteAddr == null) {
      remoteAddr = Address.getip(sa);
    }
  } catch (Exception e) {
    log.warn(sm.getString("endpoint.warn.noRemoteHost", getSocket()), e);
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
protected void populateLocalAddr() {
  if (closed) {
    return;
  }
  try {
    long socket = getSocket().longValue();
    long sa = Address.get(Socket.APR_LOCAL, socket);
    localAddr = Address.getip(sa);
  } catch (Exception e) {
    log.warn(sm.getString("endpoint.warn.noLocalAddr"), e);
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

long inetAddress = Address.info(hi.host, Socket.APR_INET,
   hi.port, 0, rootPool);

代码示例来源:origin: jboss.web/jbossweb

long sa = Address.get(Socket.APR_REMOTE, socket);
  remoteAddr = Address.getip(sa);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_LOCAL, socket);
  localName = Address.getnameinfo(sa, 0);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_REMOTE, socket);
  remoteHost = Address.getnameinfo(sa, 0);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_LOCAL, socket);
  localAddr = Address.getip(sa);
} catch (Exception e) {
  log.warn(sm.getString("http11processor.socket.info"), e);
  long sa = Address.get(Socket.APR_REMOTE, socket);
  Sockaddr addr = Address.getInfo(sa);
  remotePort = addr.port;
} catch (Exception e) {
  long sa = Address.get(Socket.APR_LOCAL, socket);
  Sockaddr addr = Address.getInfo(sa);
  localPort = addr.port;
} catch (Exception e) {

相关文章