Cartesius00
Cartesius00

Reputation: 24364

Parallel read/write on socket

Does it make sense to both write and read on a socket (SOCK_STREAM) in parallel with multiple threads? On Linux. Do those syscalls block each other?

Upvotes: 2

Views: 1319

Answers (2)

mmmmmmmm
mmmmmmmm

Reputation: 15513

It makes sense as long as there is exactly one writer and one reader thread. If you have more than one reader thread you need to lock reading if you have more than one writer thread you have to lock writing.

Upvotes: 1

MByD
MByD

Reputation: 137322

Yes, it makes sense. Since they are in separate threads they do not block each other.

Upvotes: 5

Related Questions