org.apache.tomcat.jni.Address.get()方法的使用及代码示例

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

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

Address.get介绍

[英]Return an apr_sockaddr_t from an apr_socket_t
[中]从apr\u套接字返回apr\u sockaddr\t

代码示例

代码示例来源: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: 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: 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: 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: 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: 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.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: 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: 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

/**
 * 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.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

public int getRemotePort() throws IOException {
  if (socket != 0 && context.running) {
    try {
      long sa = Address.get(Socket.APR_REMOTE, socket);
      Sockaddr addr = Address.getInfo(sa);
      return addr.port;
    } 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 populateRemoteAddr() {
  if (closed) {
    return;
  }
  try {
    long socket = getSocket().longValue();
    long sa = Address.get(Socket.APR_REMOTE, socket);
    remoteAddr = Address.getip(sa);
  } catch (Exception e) {
    log.warn(sm.getString("endpoint.warn.noRemoteAddr", getSocket()), e);
  }
}

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

public int getLocalPort() throws IOException {
  if (socket != 0 && context.running) {
    try {
      long sa = Address.get(Socket.APR_LOCAL, socket);
      Sockaddr addr = Address.getInfo(sa);
      return addr.port;
    } 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
public InetSocketAddress getLocalAddress() throws IOException {
  long s = serverSock;
  if (s == 0) {
    return null;
  } else {
    long sa;
    try {
      sa = Address.get(Socket.APR_LOCAL, s);
    } catch (IOException ioe) {
      // re-throw
      throw ioe;
    } catch (Exception e) {
      // wrap
      throw new IOException(e);
    }
    Sockaddr addr = Address.getInfo(sa);
    if (addr.hostname == null) {
      // any local address
      if (addr.family == Socket.APR_INET6) {
        return new InetSocketAddress("::", addr.port);
      } else {
        return new InetSocketAddress("0.0.0.0", addr.port);
      }
    }
    return new InetSocketAddress(addr.hostname, addr.port);
  }
}

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

@Override
protected void populateLocalPort() {
  if (closed) {
    return;
  }
  try {
    long socket = getSocket().longValue();
    long sa = Address.get(Socket.APR_LOCAL, socket);
    Sockaddr addr = Address.getInfo(sa);
    localPort = addr.port;
  } catch (Exception e) {
    log.warn(sm.getString("endpoint.warn.noLocalPort"), e);
  }
}

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

@Override
protected Long serverSocketAccept() throws Exception {
  long socket = Socket.accept(serverSock);
  if (log.isDebugEnabled()) {
    long sa = Address.get(Socket.APR_REMOTE, socket);
    Sockaddr addr = Address.getInfo(sa);
    log.debug(sm.getString("endpoint.apr.remoteport",
        Long.valueOf(socket),
        Long.valueOf(addr.port)));
  }
  return Long.valueOf(socket);
}

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

@Override
protected void populateRemotePort() {
  if (closed) {
    return;
  }
  try {
    long socket = getSocket().longValue();
    long sa = Address.get(Socket.APR_REMOTE, socket);
    Sockaddr addr = Address.getInfo(sa);
    remotePort = addr.port;
  } catch (Exception e) {
    log.warn(sm.getString("endpoint.warn.noRemotePort", getSocket()), e);
  }
}

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

long sa = Address.get(Socket.APR_REMOTE, socket);
Sockaddr addr = Address.getInfo(sa);
log.debug(sm.getString("endpoint.apr.remoteport",

相关文章