nsstream

Disable Nagle's algorithm for NSOutputStream

℡╲_俬逩灬. 提交于 2019-11-30 20:57:06
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:(NSStreamEvent)eventCode { switch (eventCode) { case NSStreamEventOpenCompleted: // Trying to get a handle to

iPhone: Catching a Connection Error With NSStream

一世执手 提交于 2019-11-30 19:45:01
I have written a program that connects to a server on a given IP using the NSStream protocol outlined in Apple's stream programming guide. The connection and transfer of data works flawlessly, however if the user specifies the wrong IP and the program attempts to open the streams it results in the program becoming unresponsive. From what I have read, the handleEvent method detects stream errors, however when I check for the condition that eventCode == NSStreamEventErrorOccurred, nothing seems to happen. My connect code is as follows: NSString *hostString = ipField.text; CFReadStreamRef

Using NSXMLParser initWithStream: no parser delegate methods received

痴心易碎 提交于 2019-11-30 16:04:43
问题 The basic problem I'm working on is using the NSStream classes to parse incoming incremental XML data. The data is never a complete XML Document, but I want to receive and process it in incremental chunks based off how much ever the socket can read. Looking at the documentation for NSXMLParser , it seems like the initWithStream: method to initialize a NSXMLParser would be the perfect solution to my problem. I can initialize the parser with a NSInputStream and then call the parse method on

Buffering NSOutputStream used as NSInputStream?

你说的曾经没有我的故事 提交于 2019-11-30 12:06:05
问题 I have this consumer class that takes an NSInputStream as argument which will be processed async, and I want to push data that comes from a producer class that requires that it has an NSOutputStream provided as its output source. Now how could I set up a buffering (or transparent) stream that acts as the output stream for the producer, and at the same time as the NSInputStream for my consumer class? I've looked a bit at the NSOutputStream +outputStreamToMemory and +outputStreamToBuffer

iPhone: Catching a Connection Error With NSStream

梦想与她 提交于 2019-11-30 04:49:18
问题 I have written a program that connects to a server on a given IP using the NSStream protocol outlined in Apple's stream programming guide. The connection and transfer of data works flawlessly, however if the user specifies the wrong IP and the program attempts to open the streams it results in the program becoming unresponsive. From what I have read, the handleEvent method detects stream errors, however when I check for the condition that eventCode == NSStreamEventErrorOccurred, nothing seems

Problem with NSStream SSL Connection

廉价感情. 提交于 2019-11-29 11:04:33
I am using NSStream with SSL property for socket connection. It works fine when I use the local IP address such as 192.168.1.77. But if I use any server like www.xyz.com (it has SecurityLevelTLSv1), it shows an error error code:-9843, Message:Operation could not be completed. (NSUnknownErrorDomain error -9843.) Here is my code: -(void) startSocket{ NSURL *website = [NSURL URLWithString:@"www.xyz.com"]; NSHost *host = [NSHost hostWithName:[website host]]; if(host) { NSLog(@"Valid host"); [NSStream getStreamsToHost:host port:443 inputStream:&iStream outputStream:&oStream] ; [self openStream]; }.

Stream to Get Data - NSInputStream

青春壹個敷衍的年華 提交于 2019-11-29 09:52:51
问题 All, I have a server that has a tcp socket stream for communication. I need to get to that stream and read the initial data that it needs to send me. My current code is as follows. To be honest, I'm going at this completely blind. I'm not sure if this is correct let alone the right thing for the job. -(void) initNetworkCommunication { //input stream NSInputStream *iStream; NSURL *url = [url initWithString:@"192.168.17.1:2004"]; [iStream initWithURL:url]; [iStream setDelegate:self]; [iStream

Playing Raw pcm audio data coming from NSStream

痴心易碎 提交于 2019-11-29 02:46:17
I am trying to play the pcm data from NSInputStream. Can anyone provide me the right approach or code to do so. I got the Audio in StreamHasData event with following code. uint8_t bytes[self.audioStreamReadMaxLength]; UInt32 length = [audioStream readData:bytes maxLength:self.audioStreamReadMaxLength]; Now how can i play bytes audio data in iphone? I worked on a similar problem, and I in the end solved it. Here is the basic of what I did. I am using a library for the sockets The below class is responsible for getting the audio and making it available to connected clients. #import <Foundation

NSStream SSL on used socket

社会主义新天地 提交于 2019-11-28 21:52:51
I am writing an application that uses NSStream's SSL functions on the iphone. I know that SSL is working because I can directly connect servers using SSL. I have encountered a problem where protocols that use starttls require me to communicate on the socket with unsecured, send the starttls command and then reuse the same socket for SSL. As far as i know nsstream connections cannot be reused and i can't start SSL on them after i have opened the connection. I thought about creating my own socket, communicating on it manually and then setting up an NSstream using the existing socket and start

NSStream and Sockets, NSStreamDelegate methods not being called

冷暖自知 提交于 2019-11-28 03:52:16
I've followed the guide Setting Up Socket Streams and have effectively duplicated that code in my class. No matter what I try the delegate methods just don't seem to get called. In the header file I have (basically): @interface myClass : NSObject <NSStreamDelegate> { NSInputStream *inputStream; NSOutputStream *outputStream; } - (void)connect; @end; The connect method: - (void)connect { CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (CFStringRef)@"host.example.com", 1234, &readStream, &writeStream); inputStream = (NSInputStream