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 6712137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:13:27+00:00 2026-05-26T08:13:27+00:00

I have an iPhone app that I run on the simulator. XCode ver 3.2.6/4.3.

  • 0

I have an iPhone app that I run on the simulator. XCode ver 3.2.6/4.3. I am trying to communicate with a radio on a serial port of a PC over wifi, both on the same server… I’ve tried NSStream and GCDAsyncSocket (just to make sure). The radio has its own IP address and port number. It’s actually a TCP/IP wifi module. After changing the remote access on the PC to accept my IP address, I am finally able to connect but I get kicked off immediately, I’m assuming it’s when I try to read or write. Same happens when using Telnet, connects then disconnects. The radio issues HELLO when someone connects, so Telnet must try to read since data is sent. I’m guessing. I thought since I am able to connect, I should be able to read/write. (Yes, newbie here)

I would appreciate any thoughts or direction. I’ve been researching for over a week now and going bonkers.

Thanks. I added the code below as well as the error message.

This is the error message:
socketDidDisconnect:withError: “Error Domain=NSOSStatusErrorDomain
Code=-9844 “The operation couldn’t be completed. (OSStatus error
-9844.)” UserInfo=0x4c38a60 {}”

- (IBAction)performConnection:(id)sender 
{
    asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];   
    NSError *error = nil;
    uint16_t port = [[[self serverPort] text] intValue];

    if (![asyncSocket connectToHost:[serverAddr text] onPort:port error:&error])
    {
        DDLogError(@"Unable to connect due to invalid configuration: %@", error);
        [self debugPrint:[NSString stringWithFormat:@"Unable to connect due to invalid configuration: %@", error]];
    }
    else
    {
        DDLogVerbose(@"Connecting...IP:%@, port:%i", [serverAddr text], port);
    }   
}

- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port
{
    DDLogInfo(@"socket:%p didConnectToHost:%@ port:%hu", sock, host, port);

    NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:3];
    [settings setObject:@"XXX.XXX.X.XXX"
             forKey:(NSString *)kCFStreamSSLPeerName];

    // In fact, don't even validate the certificate chain
    [settings setObject:[NSNumber numberWithBool:NO]
             forKey:(NSString *)kCFStreamSSLValidatesCertificateChain];
    [settings setObject:(NSString*)kCFStreamPropertySocketSecurityLevel
             forKey:(NSString*)kCFStreamSocketSecurityLevelNegotiatedSSL];

    DDLogVerbose(@"Starting TLS with settings:\n%@", settings);

    [sock startTLS:settings];

    [self debugPrint:[NSString stringWithFormat:@"socket:didConnectToHost:%@ port:%hu", host, port]];

    //[sock readDataToData:[GCDAsyncSocket CRLFData] withTimeout:-1 tag:0]; 
    [sock readDataWithTimeout:-1 tag:0];

}

- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
{
    DDLogVerbose(@"socket:didWriteDataWithTag:");
    [sock readDataWithTimeout:-1 tag:0];

}


- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
    DDLogVerbose(@"socket:didReadData:withTag:");

    NSString *response = [[NSString alloc] initWithData:data  encoding:NSASCIIStringEncoding];
    NSLog(@"read response:%@", response);
    [self debugPrint:[NSString stringWithFormat:@"Read:  \n%@",response]];
    [response release];

    //NSData *newline = [@"\n" dataUsingEncoding:NSASCIIStringEncoding]; 
    //[sock readDataToData:newline withTimeout:-1 tag: 0]; 
    [sock readDataWithTimeout:-1 tag:0];

}

- (IBAction)sendBuf:(id)sender 
{
    if ([[bufOut text] length] > 0) 
    {
            NSString *requestStr = [NSString stringWithFormat:@"%@\r\n", [bufOut text]];
        NSLog(@"Sending:%@",requestStr);
        NSData *requestData = [requestStr dataUsingEncoding:NSASCIIStringEncoding];
        [asyncSocket writeData:requestData withTimeout:-1.0 tag:0];
        [self debugPrint:[NSString stringWithFormat:@"Sent:  \n%@",requestStr]];
    }

}
  • 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-26T08:13:27+00:00Added an answer on May 26, 2026 at 8:13 am

    I found a partial solution (by sheer accident). It seems the radio or how the radio is setup only allows me to connect/read/write if my app or iMac initiates the connection. It’s fine with another PC. Both can initiate a connection and everything works. Still need to resolve this but at least I know my code is working.
    Thanks to anyone who gave my problem some thought.

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

Sidebar

Related Questions

I have an iPhone app that compiles and runs fine in the Simulator on
I have an app that has been running fine on the iPhone simulator for
I have an iPhone app that hides the status bar. However, my main view
I have an iPhone app that heavily relies on the OpenCV library; as such,
I have an iPhone app that is based on a navigation controller. I have
I have an iphone app that I built based off a tutorial (for a
I have an iPhone app that shows a simple view (View 1) that has
I have an iPhone app that uses the json-framework . I moved some of
I have an iPhone app that will incorporate liking / +1 with a global
I have a simple iphone app that's based on the CrashLanding sample app. So

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.