Threads and TCP/IP
Thomas Charron
twaffle at gmail.com
Tue Nov 22 12:25:01 EST 2005
On 11/21/05, Cole Tuininga <colet at code-energy.com> wrote:
>
> On Mon, 2005-11-21 at 18:18 -0500, Thomas Charron wrote:
> > Yes, one could say 'What about at the same time', but there really
> > isn't such a thing.. ;-)
> Even on an SMP machine?
For the most part, yes. Even with multiple processors, ONE of the
processes is going to get to that memory first. ;-)
> Just please, for the love of god, dont have multiple threads trying
> > to WRITE to the socket at the same time. Oh, it'll work.. But the
> > data won't look pretty unless the data packets are REALLY small.
> *heh* Yeah - I know better than to try that. 8)
In a prototype I wrote a long while ago, I accidently assumed that small
packets would go out immediatly, with multiple threads. Every once and a
while, the datastream got mangled becouse the buffers ended up with data
being intermingled.
As a side note, it IS perfectly ok to do this with datagram data. In my
case, I had the application have the ability to use either, using the same
structure, either streamed over TCP, or sent as UDP. Hence, my mistake.. ;-)
It was an additional request later on in the development process, and
caused me to have to rework some things a bit..
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20051122/fa32ee70/attachment.html
More information about the gnhlug-discuss
mailing list