recvfrom returns wrong IP address

G

Guest

In a pc there are two network adapters, called 1 and 2

Both machines run XP and adapter 1 has IP address 146... adapter 2 has
adress 10... and network masks separate them well.

Adapter 2 is connected to another pc which recives udp packets using
recvfrom, but the sender address returns the IP address for adapter 1, so the
program cannot reply using it.

Do you have any workaround so the correct sender address will be used?
 
C

Chuck

On Tue, 2 May 2006 07:10:02 -0700, Erik Carlsson <Erik
In a pc there are two network adapters, called 1 and 2

Both machines run XP and adapter 1 has IP address 146... adapter 2 has
adress 10... and network masks separate them well.

Adapter 2 is connected to another pc which recives udp packets using
recvfrom, but the sender address returns the IP address for adapter 1, so the
program cannot reply using it.

Do you have any workaround so the correct sender address will be used?

Erik,

If you want Computer 2 (at the other end of Adapter 2) to use the "10.n.n.n"
address for Computer 1, and it's getting a "146.n.n.n" address when resolving
the name, you'll need to make an entry in Hosts or LMHosts, on Computer 2, for
Computer 1.
<http://nitecruzr.blogspot.com/2005/07/local-name-and-address-resolution-on.html>
http://nitecruzr.blogspot.com/2005/07/local-name-and-address-resolution-on.html
 
G

Guest

Thank you for the reply,
If you want Computer 2 (at the other end of Adapter 2) to use the "10.n.n.n"
address for Computer 1, and it's getting a "146.n.n.n" address when resolving
the name, you'll need to make an entry in Hosts or LMHosts, on Computer 2, for

My problem is not name resolving. The function recvfrom returns a source
address from.sin_addr as 146.n.n.n as numbers (not name)

Computer 2 replies to that address which does not exist on the 10.n.n.n
network where it exists. So it sends the reply to it default gateway, where
it is lost forever.

It seems to me that I have found a bug in Windows. :(

I would not like to add addresses in configuration files, since we use GPRS
modems which seems to get new addresses randomly and it gets a lot overhead
keeping lists up to date.

A simple way to re-ask the question: How can I make Windows to send the
network card's ip-address as from address on the LAN and not its GPRS modem's
ip-address?

I get the same behaviour if the comupters have just one network cards and
Microsoft's loopback adapter installed. Loopback adapter addresses appear as
from addresses on the LAN.


Best regards

Erik Carlsson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top