Today I bemusedly learned: due to a lesser known feature in TCP, you can actually connect to your own (ephemeral) connecting socket.
If your ephemeral port range overlaps with the target port you're connecting to and your OS happens to use the same port for both connections, TCP will happily handshake with itself.

Normally, TCP's three-way-handshake looks like SYN -> SYN-ACK -> ACK.
TCP sends RST(reset) to any "unexpected" packet , the types of which depend on current TCP state.
However, in the SYN-Sent state (I've sent a request to handshake to the other side), a SYN response (remote trying to handshake to me) from the remote will, unexpectedly in my opinion, be accepted. It's called "simultaneous open" in RFC793.

Can happen out of the box on Winders and Linux; looks like OSX ignores the RFC and prevents loopback connections from getting the same port.
Shared publicly