Networking Forums

Networking Forums > Computer Networking > Linux Networking > multiple threads, same socket...safe?

Reply
Thread Tools Display Modes

multiple threads, same socket...safe?

 
 
JW
Guest
Posts: n/a

 
      08-11-2003, 12:30 AM
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
All my threads are disappearing. Derrick Fawsitt Broadband 4 03-29-2007 12:52 AM
How the selection of IP address is done for a tcp socket on client side if there are multiple alias configured Rohit Linux Networking 0 01-22-2007 11:34 AM
How the selection of IP address is done for a tcp socket on client side if there are multiple alias configured Rohit Linux Networking 0 01-22-2007 11:34 AM
Multiple Accept (listenning) threads zferentz@gmail.com Linux Networking 1 08-02-2006 09:27 AM
scheduling threads ? vivekian Linux Networking 2 04-18-2006 04:49 PM



1 2 3 4 5 6 7 8 9 10 11