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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:21:56+00:00 2026-05-13T14:21:56+00:00

I want to send OSC messages from iphone to another programme (max/msp) by creating

  • 0

I want to send OSC messages from iphone to another programme (max/msp) by creating and connecting to a udp socket. this works from the iphone simulator, i.e. when both apps are running on the same computer but not when i install the app on the phone itself.

I think the problem could be with specifying the IP of the remote computer. I am using the sockaddr_in struct to specify IP and port info. when i run the code in the simulator it is fine to specify the IP as INADDR_ANY:

sin_addr.s_addr = INADDR_ANY;

when i run it on the device i’m trying to convert my IP into a hexidecimal number and specifying that instead of INADDR_ANY. This doesn’t work for either the simulator or the device.

The console shows that the the socket is connecting and sending data fine but the remote programme (max/msp) doesn’t receive any data at all.

I have tried importing the right frameworks so that it should work on both device and simulator.

the full code follows:

import "UDPSocketCreate.h"

@implementation UDPSocketCreate

-(id)init
{
    in_addr_t myAddress = 0xC0A80145;
    if(self =[super init])
    {

//addr is an instance variable of type struct sockaddr_in

        memset(&addr, 0, sizeof(addr));
        addr.sin_len = sizeof(addr); 
        addr.sin_family = PF_INET;
        addr.sin_port = htons(3333);
        addr.sin_addr.s_addr = myAddress;INADDR_ANY
        connectAddr = CFDataCreate(NULL, (unsigned char *)&addr, sizeof(addr));
        
        OSC_initBuffer(&myOSCBuff, sizeof(packetBuffer), packetBuffer);
        
        NSString *address = @"/test";
        const char *utf8Address = [address UTF8String];
        int addressResult = OSC_writeAddress(&myOSCBuff, (char*)utf8Address);       
    }
    
    return self;
    
}


CFSocketRef udpSocket;

// this method is called from app delegate after init

-(void)createUDPSocketRef
{

    
    udpSocket = CFSocketCreate(NULL, PF_INET, SOCK_DGRAM, IPPROTO_UDP, kCFSocketWriteCallBack, myCallBack, NULL);
    if(udpSocket == NULL)
    {       
        NSLog(@"socket create failed");  
        return;
    }
    
    CFRunLoopSourceRef runLoopSrceRef = CFSocketCreateRunLoopSource(NULL, udpSocket, 1);
    
    CFRunLoopRef rl = CFRunLoopGetCurrent();
    
    CFRunLoopAddSource(rl, runLoopSrceRef, kCFRunLoopCommonModes);
    
}

// pressing a button on the UI triggers this method
-(void)bang
{   
    int myInt = 1;  
    
    int writeRestult = OSC_writeIntArg(&myOSCBuff, myInt);  
    
    int buffDoneResult;
    if (buffDoneResult = OSC_isBufferDone(&myOSCBuff))
    {
        NSLog(@"valid message in buff");        
        char *pack = OSC_getPacket(&myOSCBuff);
        int packSize = OSC_packetSize(&myOSCBuff);          

        CFDataRef OSCPacketWithAddressTest = CFDataCreate(NULL, pack, packSize);
        
        
        CFSocketError sendError = CFSocketSendData(udpSocket, connectAddr, OSCPacketWithAddressTest, 30);
        NSLog(@"send error: %d", sendError);
    }
    
    OSC_resetBuffer(&myOSCBuff);
    NSString *address = @"/test";
    const char *utf8Address = [address UTF8String];
    int addressResult = OSC_writeAddress(&myOSCBuff, (char*)utf8Address);   
    
}

@end

any help would be greatly appreciated

  • 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-13T14:21:57+00:00Added an answer on May 13, 2026 at 2:21 pm

    Change;

    in_addr_t myAddress = 0xC0A80145
    

    to

    in_addr_t myAddress = inet_addr("192.168.1.2");
    

    or whatever that IP is.

    S.

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

Sidebar

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.