discuss-gnustep
[Top][All Lists]
Advanced

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

Re: writeData: does not send out data for 5-10 minutes


From: Richard Frith-Macdonald
Subject: Re: writeData: does not send out data for 5-10 minutes
Date: Tue, 20 Sep 2005 12:57:18 +0100


On 19 Sep 2005, at 14:01, Andreas Höschler wrote:




Hi all,

I am opening a socket on one machine and do

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(connectionAccepted:)
    name:FBConnectionAcceptedNotification object: nil];
      [self acceptConnectionInBackgroundAndNotify];

I connect to this socket from another machine. This fires the following method:

- (void)connectionAccepted:(NSNotification *)notification
{
NSFileHandle *clientHandle = [[notification userInfo] objectForKey:NSFileHandleNotificationFileHandleItem];
   [clientHandle readInBackgroundAndNotify];
}

On the remote machine I send stuff using

    - [NSFileHandle writeData:]

and wait for

    - (void)readCompleted:(NSNotification *)notification

being called on the server end. This basically works. However, sometimes it takes 5 or more minutes before the data is received by the server. I assume that since I only sent a few bytes only and the data is kept until either more data is queued for transmission or a timeout occurs before the data is actually sent over the line. Can anybody confirm this assumption? What can i do about it? What I am looking for is some kind of flush mechanism (in NSFileHandle or directly on the socket) that sends out the data immediately regardless of how small the package is.




The assumption is (at least as far as the base library is concerned) wrong ... -writeData: sends the data immediately, no matter how small the amount. That being said, it's possible that your underlying network stack is not sending the data. Seems unlikely though.

Perhaps you aren't running the runloop? The runloop does neeed to be run in order to receive data asynchronously.









reply via email to

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