This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Advice on streams and bsd sockets


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]