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: Chris Vetter
Subject: Re: writeData: does not send out data for 5-10 minutes
Date: Mon, 19 Sep 2005 15:51:24 +0200 (MEST)

> --- Ursprüngliche Nachricht ---
> Von: Andreas Höschler <ahoesch@smartsoft.de>
> An: discuss-gnustep@gnu.org
> Betreff: writeData: does not send out data for 5-10 minutes
On Mon, 19 Sep 2005 15:01:35, Andreas wrote:
[...]
> On the remote machine I send stuff using
>       - [NSFileHandle writeData:]
> and wait for
>       - (void)readCompleted:(NSNotification *)notification
> being called on the server end.
[...]
> What I am looking foris 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.

You can do something like

  - (NSData *) dataAvailableOnSocket // yes, stupid method name :-)
  {
    unsigned bytes;

    if( -1 == ioctl(yourSocket, FIONREAD, (char *) &bytes) )
    {
      // handle ioctl error here
      // eg. raise NSFileHandleOperationException
    }

    if( 0 == bytes ) return nil; // no data available

    return [yourFilehandle readDataOfLength: bytes];
  }

to check whether there is any data on the socket and immediately use it.

-- 
Chris

-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++




reply via email to

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