How to determine use which virtual IP through NEIPv4Route?

When I create NEIPv4Settings, I add two IPs. And I set serveral NEIPv4Route in includedRoutes.

My question is how can I choose use which virtual ip as my source destination in my packet.

The source destination in my packet always is the first IP in NEIPv4Settins's addresses array.

NEIPv4Settings *ipv4Settings = [[NEIPv4Settings alloc] initWithAddresses:@[@"111.111.111.11", @"222.222.222.22"]
                                                                 subnetMasks:@[@"255.255.255.0", @"255.255.255.0"]];

NEIPv4Route *route = [NEIPv4Route defaultRoute];
route.gatewayAddress = @"222.222.222.1";
ipv4Setting.incluedRoutes = @[route];

networkSettings.IPv4Settings = ipv4Settings;



My question is how can I choose use which virtual ip as my source destination in my packet.

By binding your connection to the IP address you want. How you do that depends on the API you’re using. For Network framework, you’d use

requiredLocalEndpoint
. For BSD Sockets, you’d use
bind
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks, eskimo.

I will try.

How to determine use which virtual IP through NEIPv4Route?
 
 
Q