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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:10:22+00:00 2026-06-03T08:10:22+00:00

BACKGROUND: I made an IPhone socket application based on UDP. It works as a

  • 0

BACKGROUND:
I made an IPhone socket application based on UDP. It works as a client and server while it communicates with a Linux [Ubuntu] server.
I’m using a GCDAsyncUdpSocket to send and receive data. I also have a back-up server/client application on my Macbook to test/verify the socket communication application. It simply acts like the Linux [Ubuntu] server. It works perfect.

PROBLEM: I can’t receive any data from the Linux [Ubuntu] server.

DETAILS: I can successfully send data to the Linux server and it reacts/processes upon that data. But when the server sends replies or echoes, my iPhone app can’t see/read it.
A similar application I developed with a colleague for Android does read/see data from the server.
Please see the code below. Cheers!

This is the code for it:
.m file:

-(void)viewDidLoad
{
    [super viewDidLoad];
    backGround.userInteractionEnabled=YES;  
    udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];

    NSError *error = nil;
    if (![udpSocket bindToPort:0 error:&error]) //check ff of dit werkt!
    {
        return;
    }
    if (![udpSocket beginReceiving:&error])
    {
        return;
    }
}


- (IBAction)sendData:(id)sender 
{
    NSString *msg = messageField.text;
    NSData *data = [msg dataUsingEncoding:NSUTF8StringEncoding];
    [self sendingRealData:data];
}

-(void)sendingRealData:(NSData *) Content
{
    NSString *msg = [[NSString alloc] initWithData:Content encoding:NSUTF8StringEncoding];
    NSLog(@"msg is: %@", msg);
    NSString *host = [self getHost];
    int port = [self getPort]; 

    if ((port == 65536) && (host == @"-1"))
    {
        NSLog(@"Port and IP are not filled in!");
        [self errorManag:2]; 
    }

    else if ((port == 65536) && (host != @"-1"))
    {
        NSLog(@"return was -2");
        [self errorManag:1];
    }

    else if (host == @"-1")
    {
        NSLog(@"return was -1");
        [self errorManag:0]; 
    }

    else 
    {
        [udpSocket sendData:Content toHost:host port:port withTimeout:1 tag:tag];
        NSLog(@"Gestuurd");
    }
}

- (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data
  fromAddress:(NSData *)address
withFilterContext:(id)filterContext
{
    NSLog(@"niets."); 
    NSString *msg = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if (msg)
{
        NSLog(@"iets gekregen");
}
else
{
    NSLog(@"Error convertion");
    //[self logError:@"Error converting received data into UTF-8 String"];
}
//NSString *test = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//NSLog(@"%@",test); 
//[udpSocket sendData:data toAddress:address withTimeout:-1 tag:0];
    NSLog(@"HMMMM");
    messageField.text = [[NSString alloc] initWithFormat:@"RE: %@", msg]; 
}
  • 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-06-03T08:10:23+00:00Added an answer on June 3, 2026 at 8:10 am

    I found out that I had written in the ViewDidLoad to bind to port: 0, because this advice was given to me before.

    This caused the mobile to listen to a random port instead of port 12345. Changing the binding to port 12345 and works!

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

Sidebar

Related Questions

When using PNG files (made with Paint.NET) as background images on my web site,
Background info : I was handed a Tool, which was made using MS-Access 2007,
I am trying to build a photo frame application on iphone. I made the
I have an iPhone application that relies heavily on communicating with an external server.
In my iPhone application, I have a secondary thread that I have made for
This issue appears to affect all WebKit-based browsers, including the iPhone. First some background.
I have made an application for the iPhone but it is required to be
Background I have made a Web Service in Visual Studio, and I'm trying to
I have made a background that needs to cover the whole page. I know
So I made a background image to that is just two colored bars to

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.