Socket Programming: To receive data from multiple adpter having different default gateway

Hi,

I am writing an application to receive a data from adapter. Adapter is brodcasting UDP data.
So in my case I have two adapter which is connected to same router having following IP information -
1. Adapter 1 :-
IP : 192.168.1.32
Default Gateway : 192.168.1.1
Subnet Mask : 255.255.255.0
2. Adapter 2 :-
IP : 192.168.4.33
Default Gateway : 192.168.4.1
Subnet Mask : 255.255.255.0

Here is the router detail :

Default Gateway : 192.168.1.1
Subnet Mask : 255.255.255.0

PC is also connected to same router.
Application written in C++ is configure to receive data from any IP address.
m_nFamily = AF_INET;
m_nType = SOCK_DGRAM;
m_nProtocol = IPPROTO_UDP;
m_SockAddr.sin_addr.s_addr = INADDR_ANY;
m_SockAddr.sin_family = AF_INET;

In my case I can receive data coming from Adapter 1 but can not receive data coming from Adapter 2.
But the data coming from both the adapter I can see in Wireshark.

Work around to receive data from Adapter 2 : To receive data from adapter 2, I need to change the wireless network connection property for IPV4 and need to change "obtain IP address automatically" to "Use the following address":
Used following data to configure manually :
IP : 192.168.4.31
Default Gateway : 192.168.4.1
Subnet Mask : 255.255.255.0

But after doing this application don't see the message coming from adapter 1.
But the data from both the adapter can be seen in wireshark.

My goal is to receive data from both the adapter simultaneously.




You could set up seperate listeners for each adapter.
Topic archived. No new replies allowed.