Write-Write on a socket

Can anyone tell what happens if each end writes at the same time on the same socket ?

  • if one of them issues a read() after write() has completed, will it record into the buffer what the other sent ?

ex.
e1 writes to e2 - - - while - - - e2 writes to e1 (at the same time)

e1 read () - what will he read ?

Nothing bad happens when you write to both ends at the same time. What precisely happens when depends on a lot of things like buffers, framing, and transit time, but two-way traffic is still just business as usual. If the data has arrived by the time one of them finishes a write(), yes, a read() may be able to get it.