Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7076635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:19:19+00:00 2026-05-28T06:19:19+00:00

I have implemented a client-server transferring from Windows desktop application to iPhone App. I

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:19:20+00:00Added an answer on May 28, 2026 at 6:19 am

    Check the NSStreams’ streamStatus and streamError functions before trying to use them for reading and writing. See Apple’s NSStream Documentation for more info.

    This also may help: Setting Up Socket Streams

    EDIT:
    NSStreamStatus values:

    typedef enum {
        NSStreamStatusNotOpen = 0,
        NSStreamStatusOpening = 1,
        NSStreamStatusOpen = 2,
        NSStreamStatusReading = 3,
        NSStreamStatusWriting = 4,
        NSStreamStatusAtEnd = 5,
        NSStreamStatusClosed = 6,
        NSStreamStatusError = 7
    };
    

    You will have to wait until the status is Open before using it. It may several seconds (maybe even 30 sec) for a bad URL to resolve to status Error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a client-server transferring from Windows desktop application to iPhone App. I
I have implemented a web service with server and client authentication using keytool. The
I have a client server based windows forms application that needs an administrator only
I have implemented the client server using socket programming in C on Unix OS.
I have implemented a Kerberos server/client using sockets in Java, where the client sends
I have implemented a client server jave program using TCP for an assignment. Now
I have implemented TCp concurrent server and client in c using threads as well
I have implemented a chat service and desktop client using Java, the program works
I have a client/server style application which communicates using WCF which all works great.
I have developed a Flash application for a client (wedding RSVP) and implemented it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.