NSInputStream event question

Tima <[email protected]>
Newsgroups gmane.comp.lib.gnustep.user
Message-ID <a514a032464cbbb708b23867f965ec1a__27863.705068785$1170003196$gmane$org@tv>
Hi list,

I've send similar question before, but I'm not sure it did get through.
Sorry if you see the duplicate.

I'm learning how to work with NSStreams. I made an application
that uses NSInput/OutputStream pair for local socket.

Everything works as expected (base-1.13, gui-0.11, Linux) except that
I do not get NSEventErrorOccurred in the case of errors, when the 
server
process is stopped, for instance, or there is no socket file.


Please see the code below - do I miss anything?

In the case of no /tmp/jsond file I get

2007-01-27 21:10:30.956 StreamAppTest[8574] Setting stream from local 
socket /tmp/jsond
2007-01-27 21:10:30.957 StreamAppTest[8574] <GSLocalInputStream: 
8258390> error(2): - No such file or directory

but expect to see my own printing, something like

2007-01-27 21:10:30.956 StreamAppTest[8574] Setting stream from local 
socket /tmp/jsond
2007-01-27 21:10:30.957 StreamAppTest[8574] AppController: 
NSStreamEvent=8

Thanks a lot,
   --Tima.

Here is the complete code of the application.

------------------------StreamAppTest.m begin------------------------
#include <AppKit/AppKit.h>

@interface AppController : NSObject
{
     NSInputStream * iStream;
     NSOutputStream * oStream;
}

- (void) applicationWillFinishLaunching: (NSNotification *)not;
- (void) startIO;
- (void) stream: (NSStream *)theStream handleEvent: 
(NSStreamEvent)streamEvent;
@end


@implementation AppController : NSObject

- (void) startIO
{
     NSString * path = @"/tmp/jsond";
     NSLog( @"Setting stream from local socket %@", path );

     [NSStream getLocalStreamsToPath: path inputStream: &iStream
               outputStream: &oStream];

     [iStream setDelegate: self];

     [iStream scheduleInRunLoop: [NSRunLoop currentRunLoop]
              forMode: NSDefaultRunLoopMode];

     [iStream open];
     [oStream open];
}

- (void) stream: (NSStream *)stream handleEvent: 
(NSStreamEvent)streamEvent
{
   NSLog(@"AppController: NSStreamEvent=%d", streamEvent);
}

- (void) createMenu
{
     NSMenu * menu = [[NSMenu new] autorelease];
     [NSApp setMainMenu: menu];

     [menu addItemWithTitle:@"Quit"
           action:@selector(terminate:)
           keyEquivalent:@"q"];
}


- (void) applicationWillFinishLaunching: (NSNotification *)not
{
     [self createMenu];
     [self startIO];
}

@end

int main (int argc, const char **argv)
{
     [NSApplication sharedApplication];
     [NSApp setDelegate: [AppController new]];

     return NSApplicationMain (argc, argv);
}
------------------------------- StreamAppTest.m end 
----------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.