nsstream

iOS how can i perform multiple NSInputStream

你说的曾经没有我的故事 提交于 2021-02-08 08:05:57
问题 My app uses NSInputStream like below: inputStream.delegate = self; [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [readStream open]; and delegate: - (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent It works fine, but all other requests that i do, it queued until first is finished. I can do one per time and there is no way to do multiple concurrent requests. There is a solution ? Thank you This solution not work for me : https:

How to configure CFStream (or NSStream) for SSL handshake?

断了今生、忘了曾经 提交于 2020-01-22 20:03:29
问题 I'm using CFStream/NSStream to make http connections. I want to be able to detect that a SSL handshake fails for three cases: case A: server is not trusted case B: server is trusted but asks a client certificate case C: server is not trusted and it asks a client certificate Today without doing anithing on the SSL Properties of my CFStream, I get: case A: error -9807 case B: no error but server refuses the connection (error 500) case C: error 9807 Is there a way to configure CFStream to

How to use delegate in NSStream?

£可爱£侵袭症+ 提交于 2020-01-10 04:29:24
问题 I am a newbie in Objective-C. I am trying to learn how to work with NSStream . I just used simple code from Apple Support. This code should open a stream from a file in my Desktop and show a simple message when the delegate is called by iStream. At the end of the code, I can see the status is correct, but the delegate never gets called. What am I missing? #import <Foundation/Foundation.h> @interface MyDelegate: NSStream <NSStreamDelegate>{ } - (void)stream:(NSStream *)stream handleEvent:

NSStream TCP Keep-alive iOS

落爺英雄遲暮 提交于 2020-01-09 07:30:08
问题 I have written this code to setup a stream with a server: -(void)streamOpenWithIp:(NSString *)ip withPortNumber:(int)portNumber; { CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (__bridge CFStringRef)ip, portNumber, &readStream, &writeStream); if(readStream && writeStream) { CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); CFWriteStreamSetProperty(writeStream,

NSStream TCP Keep-alive iOS

拜拜、爱过 提交于 2020-01-09 07:29:59
问题 I have written this code to setup a stream with a server: -(void)streamOpenWithIp:(NSString *)ip withPortNumber:(int)portNumber; { CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (__bridge CFStringRef)ip, portNumber, &readStream, &writeStream); if(readStream && writeStream) { CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); CFWriteStreamSetProperty(writeStream,

Cocoa Socket Programming NSInputStream read returns 0

拟墨画扇 提交于 2020-01-03 04:45:13
问题 In my App, have setup the stream like this, (void)connectStream:(NSString *)pHostName PortNo:(int)inPortNo HasInput:(bool)bInput HasOutput:(bool)bOutput{ NSHost *host = [NSHost hostWithName:pHostName]; //host = [NSHost hostWithAddress:pHostName]; [NSStream getStreamsToHost:host port:inPortNo inputStream:&pInputStream outputStream:&pOutputStream]; [pInputStream retain]; [pOutputStream retain]; [pInputStream setDelegate:self]; [pOutputStream setDelegate:self]; bool bUseSSL = YES; if (bUseSSL) {

Parsing data after sending between iOS devices over NSStream

我的未来我决定 提交于 2019-12-30 10:56:22
问题 I have an application set up to send data between two iOS devices using NSStream s over a TCP connection. The data sent consists of two parts: An integer indicating the size of the message object to come The message object, some NSStrings and an NSData object encoded with NSKeyedArchiver The issue: When the NSData object is around 1.5Mb, I get an incomprehensible archive exception when I try to decode it. When reading the 4 bytes following where the message should be, a large number is there,

Disable Nagle's algorithm for NSOutputStream

时光怂恿深爱的人放手 提交于 2019-12-30 06:53:08
问题 I am creating a multiplayer game using MPCF. You control a spacehip on the iPad using the iPhone. I am experiencing various amount of lag and latency and buffering/pauses at random times and intervals and have now landed on Apples Technical Q&A NW26 paper that talks about disabled the Nagle Algorithm. Im trying it out but my program keeps crashing and I dont understand why. It seem to be that CFWriteStreamCopyProperty always return NULL. - (void)stream:(NSStream *)stream handleEvent:

Can an open, but inactive, NSStream that is scheduled on the main thread be moved to a different thread?

独自空忆成欢 提交于 2019-12-25 02:19:51
问题 I am using (and am required to use) a third-party framework to which I do not have source. The third-party framework handles creating an authenticated client/server connection and hands back a pair of open NSStreams. The challenge that I have is the NSStreams are scheduled on the main thread (creating situations where the UI may become unresponsive - which I would like to avoid). At the point that the streams are handed off from the third party framework, no network traffic is in progress. So

How to deal with concurrency issues brought by NSStream run loop scheduling using GCD?

核能气质少年 提交于 2019-12-23 18:19:36
问题 I have the following situation where I create a GCD dispatch queue and in it I schedule an NSStream to the current NSRunLoop , as is required in its specification for it to emit delegate events, and then I make the run loop for that thread run using [[NSRunLoop currentRunLoop run] . This generates three possible scenarios: Create a serial queue in which an initial write message is sent through the stream and other write messages are only sent when there's a delegate callback from the NSStream