NSMutableURLRequest Multiple IP Addresses

366 Views Asked by At

My NIC has multiple virtual interfaces corresponding to 10 unique IPs from my network. I have an application which I would like to run 10 instances of; each instance utilizing a unique IP address. Assuming each of the 10 instances of the app knows which IP number it should be associated with:

  • How can I instruct my NSMutableURLRequest's to send the requests off of the specified IPs?
  • Is this something that can should be set at the NSURLConnection level?
1

There are 1 best solutions below

1
On

I don't believe you can tell the NSURLRequest what IP to use, or the NSURLConnection. There certainly doesn't seem to be anything in the headers. You might have to go down to the C API's and try it there, though I'm not sure if you could do it on that level, either.

Edit: https://developer.apple.com/library/mac/documentation/Networking/Reference/SCNetworkConfiguration/Reference/reference.html#//apple_ref/c/func/SCNetworkSetSetCurrent and the related functions appear to be what you need. How to select the network interface to use in my Cocoa app