Threads and TCP/IP

Cole Tuininga colet at code-energy.com
Mon Nov 21 16:52:00 EST 2005


I've been out of network programming for a while here and was having a
random musing that I thought somebody here might be able to answer.

Let's say you have a tcp/ip socket in a given multi-threaded program.
And let's further say that you have one thread specifically for reading,
and one thread specifically for writing.

Is it legitimate to have the two threads doing their respective
operation on the socket simultaneously?  In other words, can you
simultaneously read and write a tcp/ip socket?  Or would the threads
need to do some locking themselves to make sure this doesn't happen?

This isn't a "I'm trying to..." question, I have no practical example or
reason for asking.  Just good old fashioned geek curiostiy.  8)

-- 
"Maybe I'll be able to get a job when I graduate..."
 -Linus Torvalds

Cole Tuininga
Lead Developer
Code Energy, Inc
colet at code-energy.com
PGP Key ID: 0x43E5755D





More information about the gnhlug-discuss mailing list