diff --git a/newsfragments/609.bugfix.rst b/newsfragments/609.bugfix.rst
new file mode 100644
index 00000000..2982905e
--- /dev/null
+++ b/newsfragments/609.bugfix.rst
@@ -0,0 +1,2 @@
+Fixed a race condition on macOS, where Trio's TCP listener would crash if an
+incoming TCP connection was closed before the listener had a chance to accept it.
diff --git a/trio/_highlevel_socket.py b/trio/_highlevel_socket.py
index 62b085b5..fef97622 100644
--- a/trio/_highlevel_socket.py
+++ b/trio/_highlevel_socket.py
@@ -62,11 +62,6 @@ class SocketStream(HalfCloseableStream):
             raise TypeError("SocketStream requires trio socket object")
         if socket.type != tsocket.SOCK_STREAM:
             raise ValueError("SocketStream requires a SOCK_STREAM socket")
-        try:
-            socket.getpeername()
-        except OSError:
-            err = ValueError("SocketStream requires a connected socket")
-            raise err from None
 
         self.socket = socket
         self._send_conflict_detector = ConflictDetector(

SocketStream.__init__'s check for whether the socket is connected is unreliable on MacOS
On IRC, @dstufft told me about a strange crash he sometimes gets in [linehaul](https://github.com/pypa/linehaul) when dumping test data in using netcat, which looked like it might be a bug in trio's `SocketListener` or something.

Unfortunately, I didn't save the traceback, and I'm not really sure how to reproduce it... @dstufft, any idea?
diff --git a/trio/tests/test_highlevel_open_tcp_stream.py b/trio/tests/test_highlevel_open_tcp_stream.py
index e677d4b6..707f57ec 100644
--- a/trio/tests/test_highlevel_open_tcp_stream.py
+++ b/trio/tests/test_highlevel_open_tcp_stream.py
@@ -128,9 +128,6 @@ class FakeSocket(trio.socket.SocketType):
     def setsockopt(self, *args, **kwargs):
         pass
 
-    def getpeername(self):
-        return (self.ip, self.port)
-
 
 class Scenario(trio.abc.SocketFactory, trio.abc.HostnameResolver):
     def __init__(self, port, ip_list, ipv6_supported):
diff --git a/trio/tests/test_highlevel_socket.py b/trio/tests/test_highlevel_socket.py
index aa1839d0..90f8ebd0 100644
--- a/trio/tests/test_highlevel_socket.py
+++ b/trio/tests/test_highlevel_socket.py
@@ -24,11 +24,6 @@ async def test_SocketStream_basics():
         with pytest.raises(ValueError):
             SocketStream(sock)
 
-    # disconnected socket bad
-    with tsocket.socket() as sock:
-        with pytest.raises(ValueError):
-            SocketStream(sock)
-
     a, b = tsocket.socketpair()
     with a, b:
         s = SocketStream(a)
@@ -220,10 +215,6 @@ async def test_SocketListener_accept_errors():
         def setsockopt(self, level, opt, value):
             pass
 
-        # Fool the check for connection in SocketStream.__init__
-        def getpeername(self):
-            pass
-
         async def accept(self):
             await _core.checkpoint()
             event = next(self._events)
@@ -262,3 +253,12 @@ async def test_SocketListener_accept_errors():
     with assert_checkpoints():
         s = await l.accept()
         assert s.socket is fake_server_sock
+
+
+async def test_socket_stream_works_when_peer_has_already_closed():
+    sock_a, sock_b = tsocket.socketpair()
+    await sock_b.send(b"x")
+    sock_b.close()
+    stream = SocketStream(sock_a)
+    assert await stream.receive_some(1) == b"x"
+    assert await stream.receive_some(1) == b""

pip install -e .
parse_log_pytest
pytest
pytest pytest-cov pytest-faulthandler pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
async-generator==1.10
attrs @ file:///croot/attrs_1668696182826/work
certifi @ file:///croot/certifi_1671487769961/work/certifi
coverage==7.2.7
execnet==2.0.2
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
idna==3.10
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1648562407465/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
outcome==1.3.0.post0
packaging @ file:///croot/packaging_1671697413597/work
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pytest==7.1.2
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-faulthandler==2.0.1
pytest-mock==3.11.1
pytest-xdist==3.5.0
sniffio==1.3.1
sortedcontainers==2.4.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
-e git+https://github.com/python-trio/trio.git@106991f970d13b51a65d0c94ae5e1e33227b76a8#egg=trio
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
zipp @ file:///croot/zipp_1672387121353/work

name: trio
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib-metadata=4.11.3=py37h06a4308_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - typing_extensions=4.4.0=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - async-generator==1.10
      - coverage==7.2.7
      - execnet==2.0.2
      - idna==3.10
      - outcome==1.3.0.post0
      - pytest-asyncio==0.21.2
      - pytest-cov==4.1.0
      - pytest-faulthandler==2.0.1
      - pytest-mock==3.11.1
      - pytest-xdist==3.5.0
      - sniffio==1.3.1
      - sortedcontainers==2.4.0
      - trio==0.9.0+dev
prefix: /opt/conda/envs/trio

trio/tests/test_highlevel_open_tcp_stream.py::test_one_host_quick_success trio/tests/test_highlevel_open_tcp_stream.py::test_one_host_slow_success trio/tests/test_highlevel_open_tcp_stream.py::test_basic_fallthrough trio/tests/test_highlevel_open_tcp_stream.py::test_early_success trio/tests/test_highlevel_open_tcp_stream.py::test_custom_delay trio/tests/test_highlevel_open_tcp_stream.py::test_custom_errors_expedite trio/tests/test_highlevel_open_tcp_stream.py::test_multi_success trio/tests/test_highlevel_open_tcp_stream.py::test_does_reorder trio/tests/test_highlevel_open_tcp_stream.py::test_handles_no_ipv6 trio/tests/test_highlevel_socket.py::test_SocketListener_accept_errors
trio/tests/test_highlevel_open_tcp_stream.py::test_close_on_error trio/tests/test_highlevel_open_tcp_stream.py::test_reorder_for_rfc_6555_section_5_4 trio/tests/test_highlevel_open_tcp_stream.py::test_format_host_port trio/tests/test_highlevel_open_tcp_stream.py::test_open_tcp_stream_real_socket_smoketest trio/tests/test_highlevel_open_tcp_stream.py::test_open_tcp_stream_input_validation trio/tests/test_highlevel_open_tcp_stream.py::test_one_host_quick_fail trio/tests/test_highlevel_open_tcp_stream.py::test_one_host_slow_fail trio/tests/test_highlevel_open_tcp_stream.py::test_all_fail trio/tests/test_highlevel_open_tcp_stream.py::test_no_hosts trio/tests/test_highlevel_open_tcp_stream.py::test_cancel trio/tests/test_highlevel_socket.py::test_SocketStream_basics trio/tests/test_highlevel_socket.py::test_SocketStream_send_all trio/tests/test_highlevel_socket.py::test_SocketStream_generic trio/tests/test_highlevel_socket.py::test_SocketListener trio/tests/test_highlevel_socket.py::test_SocketListener_socket_closed_underfoot trio/tests/test_highlevel_socket.py::test_socket_stream_works_when_peer_has_already_closed
newsfragments/609.bugfix.rst trio/_highlevel_socket.py
newsfragments/609.bugfix.rst trio/_highlevel_socket.py