Posts

Post not yet marked as solved
3 Replies
543 Views
Hi,We are using -[NSURLSession streamTaskWithHostName:port] for our customized socket application. We would like to tune our application's performance by setting the NSURLRequestNetworkServiceType of NSURLSessionConfiguration associated with this NSURLSession.However, based on https://developer.apple.com/documentation/foundation/nsurlrequestnetworkservicetype?language=objc, we have no idea what does each configuration mean.For example:1. NSURLNetworkServiceTypeCallSignaling: does this mean this is specialized for the control signal of VOIP application. What if we use this flag even if we are not signaling of a VOIP? Is this flag optimized for sending of small packet over the network or large chunk of bytes?2. NSURLNetworkServiceTypeResponsiveData: we did a test with this flag too. Where we continous send 100 small messages every 500ms to an echo server and measures the latency till we get response from the server. Howerver, we don't see too much difference with or without this flag. So curious what this flag really mean?Thanks,
Posted
by xpingc206.
Last updated
.
Post marked as solved
6 Replies
1.2k Views
We are using NSURLSessionStreamTask for tcp communication. We would like to get the underlying bsd socket to disable the Nagel algorithm. The issue is we are always having a NULL socket handle (get kCFStreamPropertySocketNativeHandle property) from the NSInputStream/NSOutputStream captured from NSURLSessionStreamTask.Below are the steps how we get the raw socket handler:1. Create NSURLSessionStream by usingNSURLSessionStreamTask *_streamTask = [some_session streamTaskWithHostName:_hostname port:_port];2. Capture the steams of the task by using:[_streamTask captureStreams]3. Open streams in the delegate "updateInputStream: outputStream:"- (void)updateInputStream:(NSInputStream *)inputStream outputStream:(NSOutputStream *)outputStream { if (inputStream == nil || outputStream == nil) { return; } // Cache the stream so we can use later _inputStream = inputStream; _outputStream = outputStream; [_inputStream setDelegate:self]; [_outputStream setDelegate:self]; [_inputStream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [_outputStream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [_inputStream open]; [_outputStream open];}4. We can use the _inputStream and _outputStream to send/receive data to the remote host.5. However, when trying to get kCFStreamPropertySocketNativeHandle for this _inputStream/_outputStream, NULL is always returned.CFDataRef socketData = CFWriteStreamCopyProperty((__bridge CFWriteStreamRef)_outputStream), kCFStreamPropertySocketNativeHandle);I also tried with the _inputStream by using CFReadStreamCopyProperty, but still a NULL is returned.Any idea on why NULL is returned for the input/output streams captured from NSURLSesssionStreamTask?
Posted
by xpingc206.
Last updated
.