Any way to get local tcp port from NEAppProxyTCPFlow

Hi there,

I am developing a software with Network Extension and it is half way through.

One of the requirement is to fetch back local tcp port from a tcp flow that connect to remote endpoint by createTCPConnection().

I can get the local tcp port with connection.localAddress after the the connection is connected. But that is a bit late.

If it is possible to get it from createTCPConnection, that will be perfect. But seen from the document, createTCPConnection has only remoteEndpoint, no localEndpoint.

Thanks in advance if any suggestion.
OK, I presuming we’re talking about an NWTCPConnection created using -[NWProvider createTCPConnectionToEndpoint:enableTLS:TLSParameters:delegate:]. If so, there’s no way to get the local port before the connection is established because the system doesn’t know the local port until then. That API connects you to the system’s Happy Eyeballs implementation, which may end up establishing multiple TCP connections and ‘racing them’ to find the best. Thus, until the point where the system decides on the best connection to use, the concept of the local port simply makes no sense.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Thank you for the conformation. That is clear to me :)

Any way to get local tcp port from NEAppProxyTCPFlow
 
 
Q