Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

simultaneously read and write on one socket file

0 views
Skip to first unread message

Pallav singh

unread,
Jun 11, 2009, 4:57:06 AM6/11/09
to
Hi ,

Assume a tcp/ip connection between two Linux platforms established via
the socket interface. The processes on the two platforms communicate
through a file descriptor.

Is it possible to simultaneously read and write on one socket file
descriptor from 2 threads within the process, i.e. one thread reads
data the other thread writes data at the same time on the same file
descriptor ?

Or will this screw up my data ?

Thanks
Pallav Singh

Chris McDonald

unread,
Jun 11, 2009, 5:03:53 AM6/11/09
to
Pallav singh <singh....@gmail.com> writes:

>Is it possible to simultaneously read and write on one socket file
>descriptor from 2 threads within the process, i.e. one thread reads
>data the other thread writes data at the same time on the same file
>descriptor ?


It will work but (very likely) only one thread will actually be running
at any one instant in time, unless you can schedule each thread to run
on a different core of a multicore CPU (?).

--
Chris.

0 new messages