> On Apr 13, 2015, at 8:31 AM, Jeff Johnson <publicpost...@lapcatsoftware.com> 
> wrote:
> 
> I try to get kCFStreamPropertySocketRemoteHostName and 
> kCFStreamPropertySocketRemotePortNumber from both the read stream and the 
> write stream, but again I always get NULL.

Have you tried kCFStreamPropertySocketRemoteHost? (Although I haven’t found 
this property to work either in the related case of a stream opened from an 
_incoming_ TCP connection.)

> Isn't this supposed to work? Isn't the net service supposed to resolve when 
> you open the streams?

My guess is that the address is resolved but at a lower level in the stack, and 
the resolved address doesn’t get stored into the NetService object itself. 
Which would be a bug.

Workarounds I can think of:
(a) Use a lower-level (Unix) API to get the remote address from the underlying 
socket file descriptor. I don’t know these APIs well enough to tell you how to 
do it, other than to guess that getsockopt might be involved.
(b) Instead of calling the convenience routine 
CFStreamCreatePairWithSocketToNetService, DIY by first resolving the 
NetService, getting the address, and then opening streams to it.
(c) Do without the address. There shouldn’t be much need for it, except for 
debugging purposes.

—Jens
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to