Return-Path: william@bourbon.usc.edu Delivery-Date: Sun Oct 26 21:14:52 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m9R4EptD013525 for ; Sun, 26 Oct 2008 21:14:51 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m9R4Pcba026687 for ; Sun, 26 Oct 2008 21:25:38 -0700 Message-Id: <200810270425.m9R4Pcba026687@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: Two threads sending from same Socket? Date: Sun, 26 Oct 2008 21:25:38 -0700 From: Bill Cheng Someone wrote: > In my code it can happen that two threads might write on the same Socket > Descriptor. > Will i need a Lock on the "send" portion of my code in both thread > codes.Or the kernel takes care that only one thread writes into the socket > and will not context switch it out. I've heard both sides! Some say that you cannot send() and recv() at the same time. Some say that it's no problem. If simultaneous sending and receiving doesn't work for you, you should use a mutex. -- Bill Cheng // bill.cheng@usc.edu