Return-Path: william@bourbon.usc.edu Delivery-Date: Sat Nov 15 07:39:32 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.4 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 mAFFdV1u008294 for ; Sat, 15 Nov 2008 07:39:31 -0800 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id mAFFZTSU025675 for ; Sat, 15 Nov 2008 07:35:29 -0800 Message-Id: <200811151535.mAFFZTSU025675@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: Misunderstanding TCP stream? Date: Sat, 15 Nov 2008 07:35:29 -0800 From: Bill Cheng Someone wrote: > Due to the buffer size constraints, I first send the message common header > and metadata. I then iteratively read in 'chunks' of the file data, and send > each 'chunk' individually. The common header of course tells the client how > much data to expect, including the file data. > > When I attempt this though, for some reason, the client reads in the correct > number of bytes, but the file data bytes are incorrect. And then a few > seconds later the client seg faults. Am I misunderstanding / misusing the > TCP stream? I thought this should work? Sounds like you are doing it correctly. This is also what we did for warmup #1 (except that instead of reading and writing one block at a time, we were reading and writing one byte at a time). If your warmup #1 is working properly, you can change it to do it the same way you are doing and you should see that it works. So, my guess is that the bug is somewhere else. -- Bill Cheng // bill.cheng@usc.edu