Return-Path: william@bourbon.usc.edu Delivery-Date: Mon Nov 17 20:27:36 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 mAI4RarU010144 for ; Mon, 17 Nov 2008 20:27:36 -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 mAI4OFbK002023 for ; Mon, 17 Nov 2008 20:24:15 -0800 Message-Id: <200811180424.mAI4OFbK002023@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: cs 551 question on tcp Date: Mon, 17 Nov 2008 20:24:15 -0800 From: Bill Cheng Someone wrote: > Suppose I have 2 messages queued up at my socket stream. A is a store msg > that was flooded and B is something else, say a keepalive. In part 1 I would > receive the entire message before i begin to process it. But now i first > peek into the message to see if its a store by receiving the header first > and then write the data in to a file in chunks. Now if the coin flip says > "no", there is no point in reading and writing to a file as it will be > deleted later on. So is there anyway to delete part of message A from the > socket buffer without hurting the next message B. Like the next "datalen of > A" bytes from the socket stream, so that the next recv() call will start > reading from msg B. TCP's stream of bytes abstraction does not allow you to do it! Since it's a stream of bytes, there is no concept of a message boundary. This is a problem with the protocol design of the SERVANT network. If it is going to be a real peer-to-peer network, we need to fix this. (Not a bad final exam question if we were to have long essay questions! But since we don't have long essay questions, this will not be on the exam.) -- Bill Cheng // bill.cheng@usc.edu