We need a way to deal with and detect simultaneous open. When two computers open a TCP connection with the same 5 tuple at the same time, they both get the same connection and each ends up thinking that it's the initiator. This breaks multistream-select, stream muxers, tls (eventually), etc. Worse, it causes the current go-multistream protocol negotiation to hang (because we expect the server to send us the /multistream/1.0.0 header first and both sides think they're the client).
Multistream solution
To fix this in multistream, clients could send (without waiting for the server as they currently do):
/multistream/1.0.0
iamclient
/myprotocol/1.0.0
If the server sends back:
/multistream/1.0.0
na
/myprotocol/1.0.0
We know that we're actually the client (keep the connection).
If, instead, they send back anything other than na, we know that we both think we're the client and we kill the connection.
Unfortunately, this means we'd need to build this into multistream select but, really, we only need it for TCP.
TCP solution
We could fix this by having each side that thinks its the client send an out-of-band message (yes, these exist) on the TCP channel stating "I am the client". If we receive an "I am the client" message while we think we're the client, we kill the connection. That will allow us to avoid waiting for the connection itself to timeout.
Unfortunately, this is shitty.