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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:00:52+00:00 2026-06-01T02:00:52+00:00

I use this library: https://github.com/robbiehanson/CocoaAsyncSocket My test code: #import <UIKit/UIKit.h> @class GCDAsyncUdpSocket; @interface ThirdViewController

  • 0

I use this library: https://github.com/robbiehanson/CocoaAsyncSocket

My test code:

#import <UIKit/UIKit.h>
@class GCDAsyncUdpSocket;

@interface ThirdViewController : UIViewController
{
    GCDAsyncUdpSocket *udpSocket;
}

.m:

#import "ThirdViewController.h"
#import "DDLog.h"
#import "DDTTYLogger.h"
#import "GCDAsyncUdpSocket.h"
static const int ddLogLevel = LOG_LEVEL_VERBOSE;

@implementation ThirdViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    [DDLog addLogger:[DDTTYLogger sharedInstance]];
    udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];

    [udpSocket bindToPort:7744 error:nil];
    [udpSocket beginReceiving:nil];
    [udpSocket enableBroadcast:YES error:nil];
    //[udpSocket connectToHost:@"127.0.0.1" onPort:55544 error:nil];

    NSData *data = [@"test" dataUsingEncoding:NSUTF8StringEncoding];

    //[udpSocket sendData:data withTimeout:-1 tag:0];
    [udpSocket sendData:data toHost:@"127.0.0.1" port:55544 withTimeout:-1 tag:0];
}

But the package is not sent. I used this packet sniffer: http://sourceforge.net/projects/packetpeeper/

In the library there is an example of a client (for Mac), his packages I see. I tried to run the application on a real device, but nothing was sent, too (address, of course, was the other). What is the problem?

  • 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-01T02:00:53+00:00Added an answer on June 1, 2026 at 2:00 am

    You’re listening on port 7744 and you’re transmitting to port 55544. You should be transmitting to the same port as you’re listening at. i.e. the send should be:

    [udpSocket sendData:data toHost:@"127.0.0.1" port:7744 withTimeout:-1 tag:0];
    

    An educated guess as to the reason packetkeeper isn’t seeing the packets is because they are not going out any network interface – it’s a general optimization that packets for the lo device (127.0.0.1) do not go out on the wire; they are just looped around locally. Most packet interception devices cannot detect packets of this type.

    Edit You need at least two GDCAsyncUdpSockets – one for the client, one for the server. The easiest way to accomplish this is to have two separate applications, one running as the server, the other running as the client.

    This ThirdViewController is a UDP client of some form. When you issue the bindToPort, you need to use the port number 0, this causes the OS to allocate a port for this system which is used for listening. This is needed if you ever want to receive a packet sent from the server.

    [udpSocket bindToPort:0 error:nil];
    

    as an aside, I would always check for an error on bindToPort.

    On the server side, you need to bind to a known port:

    [serverSocket bindToPort:55544 error:nil];
    

    On the client side, when you send a message you need to do (for the simulator):

    [udpSocket sendData:data toHost:@"127.0.0.1" port:55544 withTimeout:-1 tag:0];
    

    On the server side, when you receive the message in the didReceiveData handler, you are passed a fromAddress. This address corresponds to the address and port from udpSocket, and if you want to transmit a message back to the client, you can use:

    [serverSocket sendData:data toAddress:fromAddress withTimeout:-1 tag:0];
    

    I have had no difficulties sending packets to the serverSocket from the udpSocket and processing responses when I followed this methodology. I use wireshark on the Mac side to see packets coming from the iDevice. When I used the simulator, I sent to 127.0.0.1 and saw the responses on the server.

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

Sidebar

Related Questions

I am going to use this client library: https://github.com/ezmobius/redis-rb In the github page, it
I've just seen this library https://github.com/technomancy/clojure-http-client with this snippet of code on the README
I would like to use this source: https://github.com/mongodb/casbah How can I use this stuff?
i created a library to ease use of SWT: https://github.com/fab1an/uilib . I exported javadoc
I am using the SSHJ library ( https://github.com/shikhar/sshj ). I can use sshClient.newSCPFileTransfer(); to
I'm going to use django-threadedcomments library at my Django project. https://github.com/HonzaKral/django-threadedcomments The tutorial gives
I read this article: https://www.ibm.com/developerworks/java/library/j-javadev2-8/index.html The abstract class Model in Listing 2. have static
I tried to use this on my class library mylib.core.data.dll and got a successful
I just discover twitter-boostrap https://github.com/twbs/bootstrap and I'm wondering if there is a jquery library
Am trying to implement chrisbane's pull-to-refresh library for my ListView (https://github.com/chrisbanes/Android-PullToRefresh). It seems simple

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.