When you say "where the wireframe is used," I assume that you mean NSURLSession , NSURLConnection , UIWebView or WKWebView . Each of them is a slightly different situation, but in all of them the answer is that this is not possible directly (but see below, this is possible indirectly). You do not have access to the underlying sockets they use. They all use a connection pool, which complicates the situation, even if you can get a "socket". In the case of UIWebView and WKWebView single request to www.google.com can generate several independent connections, each of which can potentially interact with a different IP address.
(I am a bit delighted with what you are trying to do. Due to load balancing, one IP address does not mean one server, so IP addresses are only slightly more identifiable than CNAME. Proxies ....)
If you need such access, you need to manage the socket yourself. This is possible on all systems except WKWebView . I assume that you already know (or can easily learn) how to create a socket and execute HTTP using CFSocket and CFHTTPMessage . This is described in detail in the CFNetwork Programming Guide . If you created a socket, you can use CFSocketCopyPeerAddress to check which host you are really connected to. This is what you wanted.
Given that you can create this socket and manage it yourself, you can connect it to the main URL loaders (except WKWebView ) using NSURLProtocol . See Implementing Offline Caching for UIWebView (and NSURLProtocol) for a quick introduction and some code examples. You just need to take the request and make it using CFSocket , giving you the opportunity to see the exact port you are connected to.
source share