• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService


  • Subject: Re: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 13 Apr 2015 09:29:13 -0700

> On Apr 13, 2015, at 8:31 AM, Jeff Johnson <email@hidden> 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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService
      • From: Jeff Johnson <email@hidden>
References: 
 >Can't get remote host and port after CFStreamCreatePairWithSocketToNetService (From: Jeff Johnson <email@hidden>)

  • Prev by Date: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService
  • Next by Date: Re: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService
  • Previous by thread: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService
  • Next by thread: Re: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService
  • Index(es):
    • Date
    • Thread