nsinputstream

NSURLConnection and bound pair of streams (CFStreamCreateBoundPair or CFStreamCreateBoundPairCompat) not working on iPhone 3G

蓝咒 提交于 2019-12-13 05:41:26
问题 I'm using SimpleURLConnections example to implement multipart/form-data POST request using bound pair of streams. It works great in Simulator and on iPhone 3GS/iPhone 4. When I try it on iPhone 3G (running 3.1.3) no data gets sent to the server. NSURLConnection just keeps hanging until it times out. After some testing I figured that the problem only occurs when I write to the producer stream more than once per connection. Whenever I need to write more than once (that is when I have to respond

Cocoa Read NSInputStream from FTP connection

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:47:40
问题 I (apparently) manage to make a ftp connection, but fail to read anything from it, and with good cause: I don't reach the reading until the connection has timed out. Here's my code: header: NSInputStream *iStream; NSOutputStream *oStream; implementation: NSHost *host = [NSHost hostWithAddress:@"127.0.0.1"]; [iStream open]; // SOLUTION changes [NSStream getStreamsToHost:host port:3333 inputStream:&iStream outputStream:&oStream]; NSMutableDictionary *settings = [NSMutableDictionary

Writes to NSOutputStream after performing work on background thread don't work

喜你入骨 提交于 2019-12-12 02:25:48
问题 I have a program that is sending large files over NSStreams after some initial processing. The flow of the application goes like this: 1) Two devices connect to each other, open their input and output streams, and schedule their run loops: [self.inputStream setDelegate:self]; [self.outputStream setDelegate:self]; [self.inputStream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [self.outputStream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];

iOS: outputStream does not stay open

纵饮孤独 提交于 2019-12-10 12:19:34
问题 Okay so I'm implementing a NSOutput and Input Streams. When they are initialized, the streams open and connect to my TCPServer I have running on my PC, but then appear to close once outside of the initializing function or maybe the streams aren't being stored properly. I'm not quite sure so any assistance is greatly appreciated In my .h file: @interface AVCamViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate, NSStreamDelegate> { NSOutputStream

RN42 Bluetooth disconnects on iOS within seconds of streaming data

北慕城南 提交于 2019-12-09 13:22:58
问题 I've been trying to read data from a device via Bluetooth 2.1 using an RN-42. The device pairs to an iPhone or iPad Mini, and data is streamed across briefly, but the iOS & BT module disconnect (unpair) within seconds (less than 10). The device is outputting data 5-10kB/s, so well within Bluetooth’s spec. Something that I’ve also noticed is that when I run the function NSInputStream, [NSInputStream read: maxLength:], the number of bytes returned is always 158 or less. The app and hardware don

Error deserializing json stream

江枫思渺然 提交于 2019-12-08 07:10:57
问题 I have an NSInputStream *inputStream receiving small JSON objects from a network connection. If I read the stream to a buffer like so: NSError *err = nil; uint8_t buffer[1024]; NSMutableData *data = [[NSMutableData alloc] init]; while ([inputStream hasBytesAvailable]) { int const len = [inputStream read:buffer maxLength:sizeof(buffer)]; if (0 < len) { [data appendBytes:buffer length:len]; } } NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&err]; then I get

I cannot initialize a NSInputStream

你说的曾经没有我的故事 提交于 2019-12-06 12:08:33
Please help me, im going insane. I need to create an NSInputStream so i can read a live preview from a camera over wifi. liveViewStream is an NSInputStream -Instance-Variable that is declared in my implementation like so: @implementation MKSonyCamHandler{ NSInputStream *liveViewStream; } liveViewURL is a valid URL that i can open in my browser when i connect to the camera's network (although i dont think that this makes any difference). I have checked that it exists, is not nil and holds the value that i expect. But when i do this: liveViewStream = [[NSInputStream alloc] initWithURL

How to convert NSInputStream to NSString or how to read NSInputStream

流过昼夜 提交于 2019-12-06 09:20:38
I'm trying to convert my input stream to a string. The input stream I'm trying to convert is NSURLRequest.HTTPBodyStream, apparently the httpbody is set to null and replaced with the stream after you make the request. how do I go about doing this? This is what I have so far: #define MAX_UTF8_BYTES 6 NSString *utf8String; NSMutableData *_data = [[NSMutableData alloc] init]; //for easy 'appending' bytes int bytes_read = 0; while (!utf8String) { if (bytes_read > MAX_UTF8_BYTES) { NSLog(@"Can't decode input byte array into UTF8."); break; } else { uint8_t byte[1]; [r.HTTPBodyStream read:byte

Background Upload With Stream Request Using NSUrlSession in iOS8

删除回忆录丶 提交于 2019-12-04 02:20:18
问题 Previously in iOS7 when we try to upload with stream request in background we get following exception Terminating app due to uncaught exception 'NSGenericException', reason: 'Upload tasks in background sessions must be from a file' But in iOS8 there is no exception when we try to upload with stream in background. Now my question is 1) Is backgourd upload with uploadTaskWithStreamedRequest: allowed in iOS8? 2) In iOS8 i am using background NSURLConfiguration with uploadTaskWithStreamedRequest

RN42 Bluetooth disconnects on iOS within seconds of streaming data

和自甴很熟 提交于 2019-12-03 16:45:12
I've been trying to read data from a device via Bluetooth 2.1 using an RN-42. The device pairs to an iPhone or iPad Mini, and data is streamed across briefly, but the iOS & BT module disconnect (unpair) within seconds (less than 10). The device is outputting data 5-10kB/s, so well within Bluetooth’s spec. Something that I’ve also noticed is that when I run the function NSInputStream, [NSInputStream read: maxLength:], the number of bytes returned is always 158 or less. The app and hardware don’t crash, but the Bluetooth just unpairs. The device is still sending data to the RN42 even after the