Networking Forums

Networking Forums > Computer Networking > Linux Networking > How to get my local ethernet ip on which i receive a socket data??

Reply
Thread Tools Display Modes

How to get my local ethernet ip on which i receive a socket data??

 
 
kernel.lover
Guest
Posts: n/a

 
      03-22-2005, 05:31 AM
Hello,
I want to get my local ethernet ip on which i receive a socket
data. I have eth0: 10.0.0.100 and eth1:192.168.1.100 then how to know
on which i receive socket data. I know that i only sending data from
another pc eth:10.0.0.200 to 10.0.0.100. But how can i get that info
in my udpServer.
I have set server socket with
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
servAddr.sin_port = htons(LOCAL_SERVER_PORT);
then how t get my local IP?
regards,
cranium.
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=
Guest
Posts: n/a

 
      03-22-2005, 08:41 AM
kernel.lover wrote:
> Hello,
> I want to get my local ethernet ip on which i receive a socket
> data. I have eth0: 10.0.0.100 and eth1:192.168.1.100 then how to know
> on which i receive socket data. I know that i only sending data from
> another pc eth:10.0.0.200 to 10.0.0.100. But how can i get that info
> in my udpServer.
> I have set server socket with
> servAddr.sin_family = AF_INET;
> servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
> servAddr.sin_port = htons(LOCAL_SERVER_PORT);
> then how t get my local IP?
> regards,
> cranium.


Use getsockname() on the connected socket.
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How big is socket receive buffer, and how to control it? C. J. Clegg Linux Networking 1 04-30-2006 08:58 AM
not able to receive data over the VPN connection =?Utf-8?B?SVRUZXN0ZXI=?= Broadband Hardware 0 12-31-2004 06:15 PM
receive on socket with MSG_WAITALL flag Shanthi Paladugu Linux Networking 0 11-08-2004 04:31 PM
Possible to receive 8O1 data on serial port? Killans - First And Last And Always Linux Networking 4 08-19-2004 08:55 PM
application to receive ethernet|IP|UDP a ethernet|ppp|IP|UDP packages over socket Andreas Linux Networking 0 06-07-2004 03:24 AM



1 2 3 4 5 6 7 8 9 10 11