import _socket


def socket(self, s):
    """Adds the following fields:

        :ip_addr: numeric IP address
        :port: port number
        :host: peer hostname, as returned by :func:`getnameinfo`
        :service: the human readable name of the service on ``port``

    :arg socket s: the socket to extract information from
    """
    ip_addr, port = s.getpeername()
    host, service = _socket.getnameinfo((ip_addr, port), 0)
    return self.fields(ip_addr=ip_addr, port=port, host=host, service=service)