Hi,
(I apologize if this is not the correct forum
for this question).
I'm trying to write a C socket program (under
the RedHat linux environment) that
involves more than one thread (I'm using
the pthread library).
This application will act as a server.
Once it sees a client, I'd like the
server application to create a second
thread which is reponsible for sending
data back to the client:
write(connectedSocket,buffer1, numBytes1);
The original thread will be waiting
for incoming data from the client
(via a blocking "read" command):
read(connectedSocket,buffer2,numbytes2);
Both threads will be using the same
socket descriptor.
Since only one thread is reading and one
thread is writing (even though it's via
the same socket), do I have to worry about
using mutex to protect from possible data
loss/corruption in this scenario.
Thanks
|