public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Michael Jones <mike@proclivis.com>
To: ecos discuss <ecos-discuss@sourceware.org>
Subject: [ECOS] Advice on streams and bsd sockets
Date: Tue, 21 Jan 2014 06:35:00 -0000	[thread overview]
Message-ID: <339C0166-75DA-47B6-B019-24F898B5324A@proclivis.com> (raw)

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.

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.

Mike

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

             reply	other threads:[~2014-01-21  6:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21  6:35 Michael Jones [this message]
2014-01-21 15:10 ` [ECOS] " Grant Edwards
2014-01-21 15:43   ` [ECOS] " Michael Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=339C0166-75DA-47B6-B019-24F898B5324A@proclivis.com \
    --to=mike@proclivis.com \
    --cc=ecos-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).