Richard and Renauld,

Thank you very much for your help.

Renauld Molla wrote:

but did you check Apple's  "Stream Programming Guide for Cocoa" at

Yes, I read about it before. I did not understand how to (directly) use it for my purpouses.

On 2007-01-22 00:46:07 -0800 Richard Frith-Macdonald <[EMAIL PROTECTED]> wrote:

NSStream is probably what you want to use, but it provides per-byte I/ O. not per-character I/O. There is no API for per-character I/O, but you could subclass NSStream to add that if you really want it.

Per-byte will be perfectly fine.

NSStream can be used for buffered I/O by chaining together a memory stream and a stream that writes to a device directly.

Yes, it seemed NSStream was what I needed because I can get NSStreams for
file, memory location or socket, and this is what I want.

At the risk of holding your attention for too long, let me share my confusion about NSStream with you. NSInputStream, for instance, has [-read:maxLen:] which in my mind plays the role of select() and read() combination for sockets. I can read the available chunk of data.

This is great, but I need more that that. If I wrote in C, after

   communication_fd = accept(...);

I would call

   FILE * file = fdopen( communication_fd, "r" );

so that later I could use getc(file) and let the standard io library
call read() for me automatically when the next getc() tries to extract
a byte past the end of available data.

Shall I create a similar mechanism on the top of NSInputStream ?
Add [-readByte] to a subclass?

The closest thing to that "byte streams" I found so far was NSScanner,
but
1. It can be obtained from NSString, I did not find a way to obtain it from
    NSInputStream.
2. It can go back, scan for substrings etc., this is not possible for general
    input stream. I need just "going forward" functionality.

So it's too powerful and because of that too restrictive.
Is there something that provides a stream of bytes and
can get a new chunk behind the scenes?

Thank you,
Tima.



_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to