simultaneously read and write on the same socket in C or C++

前端 未结 3 976
轻奢々
轻奢々 2021-01-30 06:45

I am implementing a simple server, that accepts a single connection and then uses that socket to simultaneously read and write messages from the read and write threads. What is

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 07:33

    You don't have to worry about it. One thread reading and one thread writing will work as you expect. Sockets are full duplex, so you can read while you write and vice-versa. You'd have to worry if you had multiple writers, but this is not the case.

提交回复
热议问题