Determine the remote and local socket addresses used by this connection.

 Returns a two-element Array of String addresses.
541547
def addresses
      [get_peername, get_sockname].map do |addr|
        addr ? Socket.unpack_sockaddr_in(addr)[0, 2].reverse.join(':') : 'unknown'
      end
    end
1320912
function DetectLocalIPAddress(callback) {
            if (!DetectRTC.isWebRTCSupported) {
                return;
            }

            if (DetectRTC.isORTCSupported) {
                return;
            }

            getIPs(function(ip) {
                //local IPs
                if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)) {
                    callback('Local: ' + ip);
                }

                //assume the rest are public IPs
                else {
                    callback('Public: ' + ip);
                }
            });
        }
1876
public Socket get(SocketAddress remote) {
    synchronized(multimap) {
      List<Socket> sockList = multimap.get(remote);
      if (sockList == null) {
        return null;
      }
      
      Iterator<Socket> iter = sockList.iterator();
      while (iter.hasNext()) {
        Socket candidate = iter.next();
        iter.remove();
        if (!candidate.isClosed()) {
          return candidate;
        }
      }
    }
    return null;
  }
1124541
static InetAddress[] getGlobalInterfaces() throws SocketException {
        List<InetAddress> list = new ArrayList<InetAddress> ();
        for (NetworkInterface intf : getInterfaces()) {
            if (intf.isUp()) {
                for (InetAddress address : Collections.list(intf.getInetAddresses())) {
                    if (address.isLoopbackAddress() == false &&
                            address.isSiteLocalAddress() == false &&
                            address.isLinkLocalAddress() == false) {
                        list.add(address);
                    }
                }
            }
        }
        return list.toArray(new InetAddress[list.size()]);
    }
1310372
public static InetAddress getRemoteIp() {
    Call call = CurCall.get();
    if (call != null) {
      return call.connection.socket.getInetAddress();
    }
    return null;
  }
1171320
private ArrayList<String> getConnectorStrings(String name) {
        ArrayList<String> connectorStrings = new ArrayList<String>();

        try {
            MBeanServer mbeanServer = getServerForName(name);
            Set<ObjectName> objs = mbeanServer.queryNames(new ObjectName("*:type=Connector,*"), null);
            String hostname = InetAddress.getLocalHost().getHostName();
            InetAddress[] addresses = InetAddress.getAllByName(hostname);

            for (Iterator<ObjectName> i = objs.iterator(); i.hasNext(); ) {
                ObjectName obj = i.next();
                String scheme = mbeanServer.getAttribute(obj, "scheme").toString();
                String port = obj.getKeyProperty("port");
                connectorStrings.add(scheme + "://localhost:" + port);
                logger.info("Adding: {}", scheme + "://localhost:" + port);
            }
        } catch (Exception e) {
        }

        return connectorStrings;
    }
804015
async def _connect(self, remote_addresses):
        '''
        '''
        assert remote_addresses

        exceptions = []
        for remote_address in remote_addresses:
            sock = await self._connect_one(remote_address)
            if isinstance(sock, socket.socket):
                return sock, remote_address
            exceptions.append(sock)

        strings = set(f'{exc!r}' for exc in exceptions)
        raise (exceptions[0] if len(strings) == 1 else
               OSError(f'multiple exceptions: {", ".join(strings)}'))
795041
public String[] getLocalForwardings() {
		String[] r = new String[socketlisteners.size()];
		int index = 0;

		for (Enumeration<String> e = socketlisteners.keys(); e
				.hasMoreElements();) {
			r[index++] = e.nextElement();

		}
		return r;
	}
470647
@Nullable
    public static String determineIpAddress() throws SocketException {
        SocketException caughtException = null;
        for (final Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements();) {
            try {
                final NetworkInterface nextInterface = networkInterfaces.nextElement();
                if (! nextInterface.isLoopback() && ! nextInterface.isVirtual() && ! nextInterface.isPointToPoint()) {
                    for (final Enumeration<InetAddress> addresses = nextInterface.getInetAddresses(); addresses.hasMoreElements(); ) {
                        final InetAddress inetAddress = addresses.nextElement();
                        final byte[] address = inetAddress.getAddress();
                        if ((address.length == 4) //  we don't need no steenking IPv6
                                && ((address[0] != 127) || (address[1] != 0))) {    //  don't want localhost IP
                            return inetAddress.getHostAddress();
                        }
                    }
                }
            } catch (SocketException ex) {
                // We're not going to extract an IP address from this interface, so move on to the next one.
                // If we find a qualifying interface, we won't care that some other interface gave us problems.
                // If we don't find one, this exception might be informative.
                caughtException = ex;
            }
        }

        if (caughtException != null) {
            throw caughtException;
        }
        return null;
    }
773696
def local_address(self):
        
        if not self._local_address:
            self._local_address = self.proto.reader._transport.get_extra_info('sockname')
            if len(self._local_address) == 4:
                self._local_address = self._local_address[:2]
        return self._local_address
1082959
@Override
  public InetSocketAddress ipLocal()
  {
    Socket s = getSocket();
    
    if (s != null) {
      return (InetSocketAddress) s.getLocalSocketAddress();
    }
    else {
      return null;
    }
  }
654409
def fake_getaddrinfo(
        host, port, family=None, socktype=None, proto=None, flags=None):
    """"""
    return [(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP,
             '', (host, port))]
230852
private String determinateLocalIP() throws IOException {
		Socket socket = null;

		try {
			URL url = new URL(defaultRepositoryUrl);
			int port = url.getPort() > -1 ? url.getPort() : url.getDefaultPort();

			log.debug("Determinating local IP-Adress by connect to {}:{}", defaultRepositoryUrl, port);
			InetAddress address = Inet4Address.getByName(url.getHost());

			socket = new Socket();
			socket.connect(new InetSocketAddress(address, port), 3000);
			InputStream stream = socket.getInputStream();
			InetAddress localAddress = socket.getLocalAddress();
			stream.close();

			String localIp = localAddress.getHostAddress();

			log.info("Local IP-Adress is {}", localIp);

			return localIp;
		} finally {
			if (socket != null) {
				socket.close();
			}
		}
	}
766016
def getaddrinfo_wrapper(host, port, family=socket.AF_INET, socktype=0, proto=0, flags=0):
    """"""
    return orig_getaddrinfo(host, port, family, socktype, proto, flags)
880444
def address_info(self):
        """"""
        return {
            "node_ip_address": self._node_ip_address,
            "redis_address": self._redis_address,
            "object_store_address": self._plasma_store_socket_name,
            "raylet_socket_name": self._raylet_socket_name,
            "webui_url": self._webui_url,
        }
872872
SocketAddress getLocalSocketAddress() {
        // a lot could go wrong here, so rather than put in a bunch of code
        // to check for nulls all down the chain let's do it the simple
        // yet bulletproof way
        try {
            return ((SocketChannel) sendThread.sockKey.channel()).socket()
                    .getLocalSocketAddress();
        } catch (NullPointerException e) {
            return null;
        }
    }
1356686
function () {
    var self = this;

    // For the reported client address for a connection to be correct,
    // the developer must set the HTTP_FORWARDED_COUNT environment
    // variable to an integer representing the number of hops they
    // expect in the `x-forwarded-for` header. E.g., set to "1" if the
    // server is behind one proxy.
    //
    // This could be computed once at startup instead of every time.
    var httpForwardedCount = parseInt(process.env['HTTP_FORWARDED_COUNT']) || 0;

    if (httpForwardedCount === 0)
      return self.socket.remoteAddress;

    var forwardedFor = self.socket.headers["x-forwarded-for"];
    if (! _.isString(forwardedFor))
      return null;
    forwardedFor = forwardedFor.trim().split(/\s*,\s*/);

    // Typically the first value in the `x-forwarded-for` header is
    // the original IP address of the client connecting to the first
    // proxy.  However, the end user can easily spoof the header, in
    // which case the first value(s) will be the fake IP address from
    // the user pretending to be a proxy reporting the original IP
    // address value.  By counting HTTP_FORWARDED_COUNT back from the
    // end of the list, we ensure that we get the IP address being
    // reported by *our* first proxy.

    if (httpForwardedCount < 0 || httpForwardedCount > forwardedFor.length)
      return null;

    return forwardedFor[forwardedFor.length - httpForwardedCount];
  }