Trying to use GCDAsyncSocket and getting error with bad address issue

504 views
Skip to first unread message

Charlie

unread,
Apr 20, 2012, 11:42:12 AM4/20/12
to CocoaAsyncSocket
I am trying to use GCDAsyncSocket to provide a server. I had code
that used the old AsyncSocket class but I am trying to align with the
latest code.

In my new code, I call acceptOn: with a port number 1025 or greater.
In the code, it sees this as an IN_ADDR_ANY request (as I wanted it
to ).

However, I now get the error below.


4/20/12 11:27:29.598 AM Failed to start Proxy Server: Error
Domain=GCDAsyncSocketErrorDomain Code=2 "Unknown interface. Specify
valid interface by name (e.g. "en1") or IP address."
UserInfo=0x10301df50 {NSLocalizedDescription=Unknown interface.
Specify valid interface by name (e.g. "en1") or IP address.}

I am new to GCD and ARC, so I am concerned that somehow I messed
something up in the code (since this error and my use-case seem pretty
trivial).

I migrated my project to ARC using the (edit->refactor-> sequence).
The code changes all seemed pretty trivial. I did not do anything to
support GCD (I didn't think I had to).

Does any of this sound familiar to anyone? I'm perplexed!

Thanks,

Charlie


Robbie Hanson

unread,
Apr 20, 2012, 6:04:59 PM4/20/12
to cocoaasy...@googlegroups.com
In the method acceptOnInterface:port:error:, it calls this method:

- (void)getInterfaceAddress4:(NSMutableData **)interfaceAddr4Ptr
address6:(NSMutableData **)interfaceAddr6Ptr
fromDescription:(NSString *)interfaceDescription
port:(uint16_t)port

Can you see what's going on in that method for you? And if the proper address(es) are being returned.

> since this error and my use-case seem pretty trivial


I haven't encountered this problem before. Is this code running on Mac OS X or on iOS?

-Robbie Hanson

> --
> You received this message because you are subscribed to the Google Groups "CocoaAsyncSocket" group.
> To post to this group, send email to cocoaasy...@googlegroups.com.
> To unsubscribe from this group, send email to cocoaasyncsock...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cocoaasyncsocket?hl=en.
>

Charles Woloszynski

unread,
Apr 20, 2012, 6:35:45 PM4/20/12
to cocoaasy...@googlegroups.com
Yeah, I followed it into that and saw that the return values seem to get mangled.

I am trying to do several advertisements at the same time and I just switched over to ARC.

I am going to create a new project and start simple until I can find the issue. Sounds like it should work, so it is up to me to track down my environmental issue.

If I get stuck with and can easily recreate it without all the baggage, I'll re-post the issue.

Thx.

Charlie

Charlie Woloszynski

unread,
Apr 21, 2012, 8:22:07 AM4/21/12
to cocoaasy...@googlegroups.com
Looks like it was an error in an object not being retained properly.... my fault!

Charlie

Anish Gupta

unread,
Apr 20, 2012, 9:08:14 PM4/20/12
to cocoaasy...@googlegroups.com
Hi

I have been trying to connect two devices together (Iphone)by getting their ip addressees and port number.There will be a server but only for getting the ip addressees of the devices.There will be data exchange between devices.i have been searching over google but not able to find anything except this Wrapper.I am new to Xcode and programming.Can you tell which part of the code can help me.

Thanks In Advance


Andrei Stoleru

unread,
Apr 23, 2012, 2:35:26 AM4/23/12
to cocoaasy...@googlegroups.com
Hi and welcome

You should start by looking at the demo code included with the library.
Basically you use a nsnetservice to publish a service on the network and a nsnetservicebrowser to find it (from the other device). When the nsnetservicebrowser finds the service you resolve it, then use gcdasync (or udp) to connect to it. On the 'input' socket you listen (and read data) and on the 'output' socket you write data.

You should have basic knowledge of delegates and understanding of how sockets work.

Andrei

Sent from my iPhone

Reply all
Reply to author
Forward
0 new messages