Re: readInBackgroundAndNotifyForModes problems - mystery solved !
Re: readInBackgroundAndNotifyForModes problems - mystery solved !
- Subject: Re: readInBackgroundAndNotifyForModes problems - mystery solved !
- From: Alec Carlson <email@hidden>
- Date: Sun, 07 Apr 2002 20:21:48 -0500
OK, I admit it - it was my problem. I finally figured out what was going on.
I was inadvertently adding my NSFileHandle observer to the
NSNotificationCenter queue twice and so the OS was notifying me twice on
every packet it read. GIGO. My Cocoa sockets library is working much better
now. Thanks to all who responded with suggestions.
Alec Carlson
on 4/6/02 5:18 PM, Alec Carlson at email@hidden wrote:
>
I'm using NSFileHandle:readInBackgroundAndNotifyForModes to read TCP packets
>
in the background. The NSFileHandle was created by taking a socket ID
>
returned from socket() and then calling NSFileHandle:initWithFileDescriptor
>
to create an NSFileHandle out of the socket ID. I then call connect() to
>
connect to a remote server and then
>
NSFileHandle:readInBackgroundAndNotifyForModes to have NSFileHandle read
>
packets in the background and call my observer when a packet arrives.
>
>
The problem is that my observer sometimes gets called with stale data. At
>
time X, my observer gets called with packet data A. At time X+1, my observer
>
gets called again with packet data A. It should contain packet data B. I
>
know that I don't receive the data on packet boundaries. That's not the
>
issue. The problem is I receive the same data twice. It looks like I'm
>
getting the same NSData object in successive
>
NSFileHandleReadCompletionNotification calls.
>
>
Is there anything special I have to do in my observer with the NSData object
>
passed in for a NSFileHandleReadCompletionNotification callback ? Any
>
thoughts on what's going on here ? Does this work for anyone else ?
>
>
Thanx -
>
>
Alec Carlson
>
-----------------------------------------------------------------------
>
Time is Short, and the Water Rises
>
-----------------------------------------------------------------------
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
>
-----------------------------------------------------------------------
Alec Carlson
Director, Mac R & D email@hidden
Smith Micro Software, Inc.
http://www.smithmicro.com
4012 Mayflower Lane Voice: 972.491.3033
Plano, TX 75023 Fax: 972.491.3033
Time is Short, and the Water Rises
-----------------------------------------------------------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.