iOS TCP performance (NSStream)

691 views Asked by At

I'm writing an iOS application that handles a lot of TCP traffic (over WiFi).

Here's my scenario, all writes/reads are done on the dispatch queue QOS_CLASS_UTILITY.

  1. Send request for data packet (~20 bytes)
  2. Receive data packet (~100-64k bytes), parse data, send 1. again
  3. When user presses widget on the screen start sending bytes each 16ms (~20 bytes each packet)

The 1. and 2. works fine because they are chained (packets: 1, 2, 1, ...). However when user presses the widget on the screen things get messy. Looks like something blocks the connection and I don't read all the packets.

I have tried various approaches (different dispatch queues, checked if stream has enough bytes available and so on).

I know that the TCP is full-duplex and asynchronous reads/writes shouldn't be a problem, but after debugging this stuff for a week I'm out of ideas what can be wrong.

0

There are 0 answers