discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using an NSMessagePort


From: stefan
Subject: Using an NSMessagePort
Date: Tue, 6 Apr 2004 14:06:38 +0200 (CEST)
User-agent: SquirrelMail/1.4.2-3

Hi all,

i would like to use an NSMessagePort to send a bunch of data
from one thread to another. So i created two message ports and
added both to the run loop.

sendPort = [[NSMessagePort alloc] init];
[runLoop addPort: paulsPort forMode: NSDefaultRunLoopMode];

recvPort = AUTORELEASE([[NSMessagePort alloc] init]);
[recvPort setDelegate: paul];
[runLoop addPort: recvPort forMode: NSDefaultRunLoopMode];


Next, i created an NSPortMessage with an NSData object as first an only
component:

aMessage = [[NSPortMessage alloc] initWithSendPort: sendPort
                                  receivePort: recvPort
                                  components: [NSArray arrayWithObject:
                                               msgData]];

I then send five of these messages through the ports, the first one
was sent successfully (but without calling the delegate), after the
second, i get the following error:
<GSMessageHandle 0x812f120 (9) toÀBK@> - bad data received on port handle,
rType=1751477356

and a broken pipe the next time i try to sent a message. When i send
only one message, the message is sent but, my delegate is not
called.

I think, i'm doing something substantially wrong. Can someone please tell
me how to use PortMessages?

greets and thanks
Stefan







reply via email to

[Prev in Thread] Current Thread [Next in Thread]