FreeRTOS-TCP multiple interfaces.When I establish a TCP(Server or Client) connection, how should I specify which network card to use and which IP address to use

I am using FreeRTOS-TCP multiple interfaces, with two network ports (one WAN port and one LAN port), one WIFI, and one 4G. When I establish a TCP(Server or Client) connection, how should I specify which network card to use and which IP address to use? I think I should use the “FreeRTOS_bind” function, but specifically, the second parameter of “FreeRTOS_bind” in the routine is NULL

@hane_vv

Each of your network interfaces should have associated endpoints configured. During bind if when pxAddress is NULL then, based on the IP address of the target device you are trying to communicate with (server/client address), a matching endpoint (which belongs to any of the network interfaces) will be selected from the ARP/ND cache as part of the ARP/ND cache lookup of that IP. The endpoint in those caches will be based on the endpoint at which ARP/ND responses arrived. FreeRTOS_bind is used to bind a socket (either TCP or UDP) to a random local port number only when pxAddress is NULL.

If pxAddress while binding is configured to have the sin_address.ulIP_IPv4 with the IP address of any of your endpoints of your interface of interest, then the socket will be configured with that endpoint.

1 Like

@hane_vv

Agree with Tony.
Just to add as a starting point you can configure the pxAddress to the IP address of the desired endpoint of your desired interface and rest will happen as per the flow.

A reply is on its way, I am working out a configuration that should make possible what you want to do.

I will first test it in real hardware.

Hein