Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IdTCPClient on Android: Connecting to non-active network
#3
(04-26-2018, 05:16 AM)BartKindt Wrote: But when I try to connect to it, this connect request goes out over the Mobile network, NOT to the WIFI network.

Android is likely choosing to use the "active" network to make the connection. By default, Indy lets the OS pick an appropriate network interface when making outbound connections.

(04-26-2018, 05:16 AM)BartKindt Wrote: So. Is there any way I can force the IdTCPClient to specifically do a 'Connect' to via the WIFI network (of which I can get all details) as opposed to the default 'Active' network?

If you want to make an outbound connection using a specific network interface, you can set the client's BoundIP property to the IP address of that interface.

(04-26-2018, 05:16 AM)BartKindt Wrote: I tried to set the BoundIP with the local IP address assigned to the WIFI network; But this does not have any effect

Internally, the BoundIP is passed to the socket API bind() function. On most platforms, that is usually enough. But, on some systems, binding to a specific interface can also be done using the SO_BINDTODEVICE option of the socket API setsockopt() function instead (especially if you have multiple interfaces with the same IP address assigned to them). Indy does not currently support SO_BINDTODEVICE, but you can use it manually, such as in the client's OnSocketAllocated, On(Before|After)Bind, or OnStatus(hsConnecting) events, which are all fired before the socket API connect() function is called to make the connection.

Reply


Messages In This Thread
RE: IdTCPClient on Android: Connecting to non-active network - by rlebeau - 04-26-2018, 05:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)