From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12054 invoked by alias); 21 Jan 2014 15:10:35 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 12043 invoked by uid 89); 21 Jan 2014 15:10:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SEXUAL_BODY,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 X-HELO: plane.gmane.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 21 Jan 2014 15:10:32 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W5cyC-0004ql-Ih for ecos-discuss@ecos.sourceware.org; Tue, 21 Jan 2014 16:10:28 +0100 Received: from dsl.comtrol.com ([64.122.56.22]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 21 Jan 2014 16:10:28 +0100 Received: from grant.b.edwards by dsl.comtrol.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 21 Jan 2014 16:10:28 +0100 To: ecos-discuss@ecos.sourceware.org From: Grant Edwards Date: Tue, 21 Jan 2014 15:10:00 -0000 Message-ID: References: <339C0166-75DA-47B6-B019-24F898B5324A@proclivis.com> User-Agent: slrn/1.0.1 (Linux) X-IsSubscribed: yes Subject: [ECOS] Re: Advice on streams and bsd sockets X-SW-Source: 2014-01/txt/msg00019.txt.bz2 On 2014-01-21, Michael Jones wrote: > I am looking for some advice on using streams with sockets. I am using CYGPKG_NET and taking the socket handle and creating a stream with fdopen(). > > A fwrite() eventually arrives in this code: > > static int > bsd_lseek(struct CYG_FILE_TAG *fp, off_t *pos, int whence) > { > return ESPIPE; > } > > And this causes an error, but a second call to fwrite() works. It > always happens when there is a fwrite() immediately after a fread(), > as that triggers the seek. > > I am looking for advice on how to handle this problem. What I would do is first add a diag_printf() to bsd_lseek() to print out the paramters so you can see exactly what sort of seek is being attempted. You could add a bit of code to bsd_lseek() to check for (and return success for) "noop" operations (e.g. seek to 0 offset from current location). > Of course I could not use streams, but I am working with lua 5.2.3 > and it is based on streams, and don't want to modify it that much. I > also can't turn off buffering, because lua relies on the ability to > push bytes back into the stream after reading them. > > Does anyone have a patch that works around the problem or know of > some other way to create a stream that does not rely on seek? In the > case where I use it, there is no need for seek anyway. I am using the > stream in place of stdin and stdout so that lua can interact with a > telnet session. If the code works OK with stdin/stdout streams, then the lseek() calls must not be actually doing anything, right? If that's the case, then it should be easy enough to modify the the bsd_lseek() function to do the same. -- Grant Edwards grant.b.edwards Yow! I haven't been married at in over six years, but we gmail.com had sexual counseling every day from Oral Roberts!! -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss