I have implemented a client-server transferring from Windows desktop application to iPhone App. I transfer data using NSStream in polling mode (synchronous).
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)urlStr, portNo, &readStream, &writeStream);
inputStream = (NSInputStream *)readStream;
outputStream = (NSOutputStream *)writeStream;
[inputStream open];
[outputStream open];
All works fine, but when I attempt to connect an inexistent server or a disconnected server or the port number/ip address is wrong, the WRITE method of NSOutputStream object, stops the application execution.
const uint8_t *str = (uint8_t *) [strRichiesta cStringUsingEncoding:NSASCIIStringEncoding];
[outputStream write:str maxLength:strlen((char*)str)];
Is it possible to manage the method by inserting timeout control? If yes, how can I do?
I think that the same problem occurs also with READ method of NSInputStream object.
Could someone help me, please?