We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Failing `socket_info.getpeername()` with uvloop against a UDS.
When running against a unix domain socket, we seem to occassionaly get an OSError when looking up the remote address. This appears to only occur with `uvloop`.

```
ERROR:    Exception in callback HttpToolsProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)
handle: <Handle HttpToolsProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/events.py", line 127, in _run
    self._callback(*self._args)
  File "/Users/tomchristie/GitHub/encode/uvicorn/uvicorn/protocols/http/httptools_impl.py", line 129, in connection_made
    self.client = get_remote_addr(transport)
  File "/Users/tomchristie/GitHub/encode/uvicorn/uvicorn/protocols/utils.py", line 8, in get_remote_addr
    info = socket_info.getpeername()
OSError: [Errno 22] Invalid argument
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `uvicorn/protocols/utils.py`
Content:
```
1 import socket
2 
3 
4 def get_remote_addr(transport):
5     socket_info = transport.get_extra_info("socket")
6     if socket_info is not None:
7         info = socket_info.getpeername()
8         family = socket_info.family
9         if family in (socket.AF_INET, socket.AF_INET6):
10             return (str(info[0]), int(info[1]))
11         return None
12     info = transport.get_extra_info("peername")
13     if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:
14         return (str(info[0]), int(info[1]))
15     return None
16 
17 
18 def get_local_addr(transport):
19     socket_info = transport.get_extra_info("socket")
20     if socket_info is not None:
21         info = socket_info.getsockname()
22         family = socket_info.family
23         if family in (socket.AF_INET, socket.AF_INET6):
24             return (str(info[0]), int(info[1]))
25         return None
26     info = transport.get_extra_info("sockname")
27     if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:
28         return (str(info[0]), int(info[1]))
29     return None
30 
31 
32 def is_ssl(transport):
33     return bool(transport.get_extra_info("sslcontext"))
34 
35 
36 def get_client_addr(scope):
37     client = scope.get("client")
38     if not client:
39         return ""
40     return "%s:%d" % client
41 
42 
43 def get_path_with_query_string(scope):
44     path_with_query_string = scope.get("root_path", "") + scope["path"]
45     if scope["query_string"]:
46         path_with_query_string = "{}?{}".format(
47             path_with_query_string, scope["query_string"].decode("ascii")
48         )
49     return path_with_query_string
50
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/uvicorn/protocols/utils.py b/uvicorn/protocols/utils.py
--- a/uvicorn/protocols/utils.py
+++ b/uvicorn/protocols/utils.py
@@ -4,8 +4,16 @@
 def get_remote_addr(transport):
     socket_info = transport.get_extra_info("socket")
     if socket_info is not None:
-        info = socket_info.getpeername()
-        family = socket_info.family
+        try:
+            info = socket_info.getpeername()
+        except OSError:
+            # This case appears to inconsistently occur with uvloop
+            # bound to a unix domain socket.
+            family = None
+            info = None
+        else:
+            family = socket_info.family
+
         if family in (socket.AF_INET, socket.AF_INET6):
             return (str(info[0]), int(info[1]))
         return None

{"golden_diff": "diff --git a/uvicorn/protocols/utils.py b/uvicorn/protocols/utils.py\n--- a/uvicorn/protocols/utils.py\n+++ b/uvicorn/protocols/utils.py\n@@ -4,8 +4,16 @@\n def get_remote_addr(transport):\n     socket_info = transport.get_extra_info(\"socket\")\n     if socket_info is not None:\n-        info = socket_info.getpeername()\n-        family = socket_info.family\n+        try:\n+            info = socket_info.getpeername()\n+        except OSError:\n+            # This case appears to inconsistently occur with uvloop\n+            # bound to a unix domain socket.\n+            family = None\n+            info = None\n+        else:\n+            family = socket_info.family\n+\n         if family in (socket.AF_INET, socket.AF_INET6):\n             return (str(info[0]), int(info[1]))\n         return None\n", "issue": "Failing `socket_info.getpeername()` with uvloop against a UDS.\nWhen running against a unix domain socket, we seem to occassionaly get an OSError when looking up the remote address. This appears to only occur with `uvloop`.\r\n\r\n```\r\nERROR:    Exception in callback HttpToolsProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)\r\nhandle: <Handle HttpToolsProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>\r\nTraceback (most recent call last):\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/events.py\", line 127, in _run\r\n    self._callback(*self._args)\r\n  File \"/Users/tomchristie/GitHub/encode/uvicorn/uvicorn/protocols/http/httptools_impl.py\", line 129, in connection_made\r\n    self.client = get_remote_addr(transport)\r\n  File \"/Users/tomchristie/GitHub/encode/uvicorn/uvicorn/protocols/utils.py\", line 8, in get_remote_addr\r\n    info = socket_info.getpeername()\r\nOSError: [Errno 22] Invalid argument\r\n```\n", "before_files": [{"content": "import socket\n\n\ndef get_remote_addr(transport):\n    socket_info = transport.get_extra_info(\"socket\")\n    if socket_info is not None:\n        info = socket_info.getpeername()\n        family = socket_info.family\n        if family in (socket.AF_INET, socket.AF_INET6):\n            return (str(info[0]), int(info[1]))\n        return None\n    info = transport.get_extra_info(\"peername\")\n    if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:\n        return (str(info[0]), int(info[1]))\n    return None\n\n\ndef get_local_addr(transport):\n    socket_info = transport.get_extra_info(\"socket\")\n    if socket_info is not None:\n        info = socket_info.getsockname()\n        family = socket_info.family\n        if family in (socket.AF_INET, socket.AF_INET6):\n            return (str(info[0]), int(info[1]))\n        return None\n    info = transport.get_extra_info(\"sockname\")\n    if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:\n        return (str(info[0]), int(info[1]))\n    return None\n\n\ndef is_ssl(transport):\n    return bool(transport.get_extra_info(\"sslcontext\"))\n\n\ndef get_client_addr(scope):\n    client = scope.get(\"client\")\n    if not client:\n        return \"\"\n    return \"%s:%d\" % client\n\n\ndef get_path_with_query_string(scope):\n    path_with_query_string = scope.get(\"root_path\", \"\") + scope[\"path\"]\n    if scope[\"query_string\"]:\n        path_with_query_string = \"{}?{}\".format(\n            path_with_query_string, scope[\"query_string\"].decode(\"ascii\")\n        )\n    return path_with_query_string\n", "path": "uvicorn/protocols/utils.py"}], "after_files": [{"content": "import socket\n\n\ndef get_remote_addr(transport):\n    socket_info = transport.get_extra_info(\"socket\")\n    if socket_info is not None:\n        try:\n            info = socket_info.getpeername()\n        except OSError:\n            # This case appears to inconsistently occur with uvloop\n            # bound to a unix domain socket.\n            family = None\n            info = None\n        else:\n            family = socket_info.family\n\n        if family in (socket.AF_INET, socket.AF_INET6):\n            return (str(info[0]), int(info[1]))\n        return None\n    info = transport.get_extra_info(\"peername\")\n    if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:\n        return (str(info[0]), int(info[1]))\n    return None\n\n\ndef get_local_addr(transport):\n    socket_info = transport.get_extra_info(\"socket\")\n    if socket_info is not None:\n        info = socket_info.getsockname()\n        family = socket_info.family\n        if family in (socket.AF_INET, socket.AF_INET6):\n            return (str(info[0]), int(info[1]))\n        return None\n    info = transport.get_extra_info(\"sockname\")\n    if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:\n        return (str(info[0]), int(info[1]))\n    return None\n\n\ndef is_ssl(transport):\n    return bool(transport.get_extra_info(\"sslcontext\"))\n\n\ndef get_client_addr(scope):\n    client = scope.get(\"client\")\n    if not client:\n        return \"\"\n    return \"%s:%d\" % client\n\n\ndef get_path_with_query_string(scope):\n    path_with_query_string = scope.get(\"root_path\", \"\") + scope[\"path\"]\n    if scope[\"query_string\"]:\n        path_with_query_string = \"{}?{}\".format(\n            path_with_query_string, scope[\"query_string\"].decode(\"ascii\")\n        )\n    return path_with_query_string\n", "path": "uvicorn/protocols/utils.py"}]}