2

My eth1 : IP adrress is something like a:b:c:d

What i get in server that is router given address (public ip): e:f:g:h

is there any way to find the local ip address of the system in C and must be udp

Robel Sharma
  • 964
  • 1
  • 11
  • 26
  • 2
    UDP is a protocol *above* IP - it doesn't have it's own IP address. Also what O/S are you talking about; I assume Linux given the interface name? – trojanfoe Oct 26 '11 at 09:53
  • 1
    Put more effort into your question. It's hard to tell what you are asking. – cnicutar Oct 26 '11 at 09:53
  • possible duplicate of [Linux / C++: Get the IP Address of local computer](http://stackoverflow.com/questions/212528/linux-c-get-the-ip-address-of-local-computer) – trojanfoe Oct 26 '11 at 09:54

1 Answers1

1

If your client is behind a NAT:ing firewall or router, then no, there's no way for the server to directly see the client's LAN IP address. Often, such addresses are "LAN only" (non-routable) e.g. 192.168.x.y or 10.x.y.z.

If using your own custom protocol, then you can of course embed the information in a datagram and send it to the server, but beware that there's a large change the address information is completely useless to the server, for the above-mentioned reason.

unwind
  • 391,730
  • 64
  • 469
  • 606
  • Doesn't he want his own address (I think his computer is the client)? – trojanfoe Oct 26 '11 at 09:56
  • trojanfoe@ yes, My one pc is client and another one is 8 core server.It is basically a udp client-server multithreading experiment, where i am checking how much the load it can take.When i use inet_ntoa i get the client address which is not my real address. – Robel Sharma Oct 26 '11 at 10:32
  • unwind@ i liked your thinking and trying to do something like that. – Robel Sharma Oct 26 '11 at 10:33