Thursday, May 9, 2024
HomeiOS Developmentios - Cannot use a couple of pair of Basis sure streams...

ios – Cannot use a couple of pair of Basis sure streams without delay


I’ve a category that makes use of a “sure pair” of Basis streams, created with the getBoundStreams(withBufferSize:inputStream:outputStream:) technique. The InputStream of the sure pair is used to stream request physique knowledge right into a URLRequest by way of the httpBodyStream property, whereas I feed knowledge in by way of the pair’s OutputStream.

After I create one sure pair of Basis streams & use it for a URLRequest, it really works superb – the OutputStream informs its delegate when it has house accessible, it accepts knowledge by way of its write(_:maxLength:) perform, and this continues till all the info has been accepted; then I shut the OutputStream, the InputStream closes as nicely, and my URLRequest has been despatched with the streamed request physique.

However when I attempt to create two pairs or extra of sure streams at a time and try to make use of them concurrently, just one pair works. I’ve tried from one to 10 sure stream pairs at a time, and in each case, one pair succeeds and all the opposite pairs fail as follows.

On the failed stream pairs, the next occasions happen:

  • I set my StreamDelegate on the OutputStream, then open it with open().
  • The OutputStream opens, and the .hasSpaceAvailable occasion is delivered to its delegate.
  • I attempt to write to the OutputStream with write(_:maxLength:), however the return worth is -1 indicating an error occurred.
  • I question the OutputStream‘s streamStatus and the standing is 5 (.atEnd).
  • I question the OutputStream‘s streamError and it’s nil.

I’ve tried configuring my OutputStreams to ship occasions on each a RunLoop and on a GCD queue, and it fails the identical both approach. I all the time entry the stream on its configured RunLoop or GCD queue, by no means from some other context.

I see completely nothing within the Basis Stream docs about limiting the variety of pairs of sure streams or interactions between coexistent pairs of sure streams.

So what is going on on right here? Anybody seen the identical with sure pairs of Basis streams? Am I lacking one thing in my config wanted to make this work, or lacking one thing within the docs that claims a number of simultaneous stream pairs isn’t supported? Thanks!



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments