nsstream

NSStream, UTF8String & NSString... Messy Conversion

I am constructing a data packet to be sent over NSStream to a server. I am trying to seperate two pieces of data with the a '§' (ascii code 167). This is the way the server is built, so I need to try to stay within those bounds... unichar asciiChar = 167; //yields @"§" [self setSepString:[NSString stringWithCharacters:&asciiChar length...

Objective-C: Reading a file line by line

What is the appropriate way of dealing with large text files in Objective-C? Let's say I need to read each line separately and want to treat each line as an NSString. What is the most efficient way of doing this? One solution is using the NSString method: + (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding...

Problem with NSStream SSL Connection

Hi all, 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: ...

NSStream reading\writing outside the delegate method handleEvent:eventCode

Hi, in an iPhone app, I have a socket connection through wifi, and I need to read from inputStream and write to outputStream. The problem is that stream management is event-driven, and I have to wait for event NSStreamEventHasBytesAvailable before reading. So I can't know when reading\writing outside the handleEvent:eventCode delegate me...

NSStream SSL on used socket

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....

iPhone SDK: phone to phone file transfer

Hello, What is the simpliest approach to copy files from iPhone to iPhone (p2p). The only way I can come up is this: Use Bonjour to discover server app (which will advertize itself via Bonjour) Use NSStream (or sockets) and then stream data from the file from peer to peer (read chunk of the file, send chunk of the file and so on un...

iPhone, I can send accelerometer data via wifi only 248 lines

I have created one application on iPhone. I build an application that gather accelerometer value and pass this value to c# server in realtime via wifi connection. I use NSStream with IP and port number. I was working perfectly, but now I realize that it stops after fetch value only 248 lines. I tried to write this value in text file l...

Streaming JPEGs, detect end of JPEG

I have created a java server, which takes screenshots, resizes them, and sends them over TCP/IP to my iPhone application. The application then uses NSInputStream to collect the incoming image data, create an NSMutableData instance with the byte buffer, and then create a UIImage object to display on the iPhone. Screenshare, essentially....

Recording Audio on iPhone and Sending Over Network with NSOutputStream

I am writing an iPhone application that needs to record audio from the built-in microphone and then send that audio data to a server for processing. The application uses a socket connection to connect to the server and Audio Queue Services to do the recording. What I am unsure of is when to actually send the data. Audio Queue Services f...

Cocoa NSStream TCP connection to FTP

Hi, I'm new to Cocoa, but not to programming. Recently I decided I wanted to write a FTP client for Mac, and so I first made it in the language I'm most comfortable in (on Windows), and then moved on to Cocoa when I had the workings of FTP communications down. My question is (apparently) a bit controversial: How do I establish a read/w...

Cocoa NSStream works with SSL, with socks5, but not at the same time

Upon connecting (to an FTP, at first without SSL) I run: NSArray *objects = [NSArray arrayWithObjects:@"proxy.ip", [NSNumber numberWithInt:1080], NSStreamSOCKSProxyVersion5, @"user", @"pass", nil]; NSArray *keys = [NSArray arrayWithObjects:NSStreamSOCKSProxyHostKey, NSStreamSOCKSProxyPortKey, NSStreamSOCKSProxyVersionKey, NSStreamSOCKSP...

how can i Iphone EAAccessory callback speed modify?

i'am test my bluetooth device connectting and data read. but data read callback time is very slow. callback Interval time 100ms.. how can i read callback time fastest? - (void)openSessionForProtocol { NSString *protocolString = @"com.company.datapath"; NSArray *accessories = [[EAAccessoryManager sharedAccessoryManager] connectedAc...

NSStream sockets missing data

I am trying to pull some sample data from FreeDB as a proof of concept, but I am having a tough time retrieving all of the data off the incoming stream (I am only getting the last bits for the final query listed here (if handshakeCode = 3) I think this may be something with the threading on the main runloop, but I am not sure. Odd thing...

Problems in getting data from CFStreamCreatePairWithSocketToHost

Hi I'm building an iPhoe app with a socket to a PC app , I need to get an image from this PC app. It's my first time using "CFStreamCreatePairWithSocketToHost".After I establish the socket with "NSOperation" I call CFStreamClientContext streamContext = {0, self, NULL, NULL, NULL}; BOOL success = CFReadStreamSetClient(myReadStream, kMyNe...

how to disable Nagle algorithm on TCP connectio on iPhone

Hi I'm building a socket , using CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (CFStringRef) yourHostAsNSString, yourPortAsInteger, &myReadStream, &myWriteStream); and I s...

Buffering NSOutputStream used as NSInputStream?

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, a...

NSStream hangs on close

I have an NSInputStream and an NSOutputStream in an iphone app that are connected to a server. I am able to read and write data to the sockets without issue. The problem is that I have a disconnect button, and when I try to call close on either of the streams it hangs the app. I'm guessing that I am trying to call close at the wrong time...

NSURLRequest with HTTPBody input stream: Stream sends event before being opened

I want to send a large amount of data to a server using NSURLConnection (and NSURLRequest). For this I create a bound pair of NSStreams (using CFStreamCreateBoundPair(...)). Then I pass the input stream to the NSURLRequest (-setHTTPBodyStream:) and schedule the output stream on the current run loop. When the run loop continues, I get the...

iPhone: Catching a Connection Error With NSStream

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 wha...

NSData dataWithBytesNoCopy from NSInputStream

I'm working on transcoding image data from a file to a base64 encoded string and then back to bytes as the file is read using NSStream. I think I'm almost there, but I keep running into EXC_BAD_ACCESS at various points during the conversion. I'm fairly new to the world of NSStream and buffers so feel free to let me know if I'm taking th...