View Single Post
Hello,

Disclaimer: it has been years since I tried programming for OS X the last time.

Now, I just cannot manage to get OmniNetworking working. The sample code in OmniNetworking/Examples/TCPTest/ compiles fine (after creating a new .xcodeproj, the .pbproj project file is reported to be incompatible with my App Store-purchased XCode). However, when running the resulting binary with the -receive flag and a port (over 1024), it throws an exception: ONHostHasNoAddressesExceptionName. I have nailed this down to ONHost.m line 333:

Code:
NSString *lowercaseHostname = [aHostname lowercaseString];
where aHostName suddenly has an invalid address... That variable was just fine before trying to find the host name it contained in the hostCache.

A smaller example that is non-working in the same way is:

Code:
#import <Foundation/Foundation.h>
#import <OmniBase/OmniBase.h>
#import <OmniNetworking/OmniNetworking.h>

int main (int argc, const char * argv[])
{

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSString *hostName;
    unsigned short hostPort;
    ONHost *host;
    
    hostName = [[NSString alloc] initWithString: [ONHost localHostname]];
    
    hostPort = 2357;

    host = [ONHost hostForHostname:hostName]; // exception thrown here
    if (![[host addresses] count]) {
        fprintf(stderr, "Cannot determine an address for %s\n", argv[2]);
        exit(1);
    }
    
    [hostName release];
    [pool drain];
    exit(0);
    return 0;
}
Can somebody help me out here? What am I doing wrong?

Last edited by tageborg; 2011-04-05 at 01:28 PM.. Reason: Wrong line number fixed.