@Override public InetAddress getLocalAddress() { return sock.getLocalAddress(); }
private String buildHostnameToReport() { InetAddress localAddress = socket.getLocalAddress(); // we use local ip statically for privacy reasons, see https://github.com/k9mail/k-9/pull/3798 if (localAddress instanceof Inet6Address) { return "[IPv6:::1]"; } else { return "[127.0.0.1]"; } }
public InetAddress getLocalAddress() { if (this.socket != null) { return this.socket.getLocalAddress(); } else { return null; } }
public InetAddress getLocalAddress() { if (this.socket != null) { return this.socket.getLocalAddress(); } else { return null; } }
public String socketDescription() { Socket socket = transportLayer.socketChannel().socket(); if (socket.getInetAddress() == null) return socket.getLocalAddress().toString(); return socket.getInetAddress().toString(); }
private InetAddress serverAddress() { return transportLayer.socketChannel().socket().getLocalAddress(); }
/** * See {@link Socket#getLocalAddress()}. Calling this method does not trigger mode detection. */ @Override public InetAddress getLocalAddress() { return getSocketAllowUnknownMode().getLocalAddress(); }
protected String getSockAddress() { StringBuilder sb=new StringBuilder(); if(sock != null) { sb.append(sock.getLocalAddress().getHostAddress()).append(':').append(sock.getLocalPort()); sb.append(" - ").append(sock.getInetAddress().getHostAddress()).append(':').append(sock.getPort()); } return sb.toString(); }
InetAddress inetAddress = socket.getLocalAddress();
// output on my machine: "192.168.1.102" Socket s = new Socket("192.168.1.1", 80); System.out.println(s.getLocalAddress().getHostAddress()); s.close(); // output on my machine: "127.0.1.1" System.out.println(InetAddress.getLocalHost().getHostAddress());
public void go() throws IOException { final ServerSocket s = new ServerSocket(listenPort); final ExecutorService exe = Executors.newCachedThreadPool(); while (true) { final Socket incoming = s.accept(); ip = incoming.getLocalAddress().getHostAddress(); System.out.println("New Client Connected from " + incoming.getInetAddress().getHostName() + "... "); exe.submit(new FtpLoop(incoming, this)); } }
public SocketAddress getLocalAddress() { final Socket socket = conduit.getSocketChannel().socket(); return new InetSocketAddress(socket.getLocalAddress(), socket.getLocalPort()); }
/** * Returns the local address and port of this socket as a SocketAddress or * null if the socket is unbound. This is useful on multihomed * hosts. */ public SocketAddress getLocalSocketAddress() { if (!isBound()) { return null; } return new InetSocketAddress(getLocalAddress(), getLocalPort()); }
public static String getClientIp(String serviceUrl) { try { URL url = new URL(serviceUrl); int port = url.getPort(); if (port == -1) { port = url.getDefaultPort(); } try (Socket socket = new Socket(url.getHost(), port)) { return socket.getLocalAddress().getHostAddress(); } } catch (Exception e) { return SystemUtil.getFirstLocalNonLoopbackIpAddress(); } } }
o.write("Jenkins-Session: " + Jenkins.SESSION_HASH + "\r\n"); o.write("Client: " + s.getInetAddress().getHostAddress() + "\r\n"); o.write("Server: " + s.getLocalAddress().getHostAddress() + "\r\n"); o.write("Remoting-Minimum-Version: " + RemotingVersionInfo.getMinimumSupportedVersion() + "\r\n"); o.flush();
private void port() throws IOException { write("PORT " + controlSocket.getLocalAddress().getHostAddress().replace('.', ',') + ',' + (dataPort >> 8) + ',' + (dataPort & 255) + "\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to configure data port"); } }
private String id(SocketChannel channel) { return channel.socket().getLocalAddress().getHostAddress() + ":" + channel.socket().getLocalPort() + "-" + channel.socket().getInetAddress().getHostAddress() + ":" + channel.socket().getPort(); }
@Signature public Memory getLocalAddress(Environment env, Memory... args) { return new StringMemory(socket.getLocalAddress().toString()); }
public String toString() { Socket tmp_sock=sock; if(tmp_sock == null) return "<null socket>"; InetAddress local=tmp_sock.getLocalAddress(), remote=tmp_sock.getInetAddress(); String local_str=local != null? Util.shortName(local) : "<null>"; String remote_str=remote != null? Util.shortName(remote) : "<null>"; return String.format("%s:%s --> %s:%s (%d secs old) [%s] [recv_buf=%d]", local_str, tmp_sock.getLocalPort(), remote_str, tmp_sock.getPort(), TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS), status(), receiver != null? receiver.bufferSize() : 0); }
public static String bindIp() { String bindIp; try (Socket s = new Socket("www.google.com", 80)) { bindIp = s.getLocalAddress().getHostAddress(); System.out.printf("UDP local bound to: %s%n", bindIp); } catch (IOException e) { System.out.printf("Can't get bind IP. Fall back to 0.0.0.0: " + e); bindIp = "0.0.0.0"; } return bindIp; } }