Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-22-2005, 06:31 AM
Default How to get my local ethernet ip on which i receive a socket data??



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.


kernel.lover
Reply With Quote
  #2  
Old 03-22-2005, 09:41 AM
=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=
Guest
 
Posts: n/a
Default Re: How to get my local ethernet ip on which i receive a socket data??

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

Tags
data, ethernet, local, receive, socket

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
Forum Jump


All times are GMT. The time now is 07:45 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.