Local IP address
Richard M. Barry
R.Barry at sstl.co.uk
Mon Oct 20 12:19:04 UTC 2003
Thomas,
I tried your code, but I get a compiler error: "sizeof applied to an incomplete type" for the rtems_bsdnet_config() line.
Richard
-----Original Message-----
From: Thomas Rauscher [mailto:trauscher at loytec.com]
Sent: Mon 20/10/2003 11:23
To: Richard M. Barry; rtems-users at rtems.com
Cc:
Subject: RE: Local IP address
> -----Original Message-----
> From: Richard M. Barry [mailto:R.Barry at sstl.co.uk]
> Sent: Monday, October 20, 2003 11:16 AM
> To: rtems-users at rtems.com
> Subject: Local IP address
>
>
> How can I get the local IP address (the server's address, not
> the client's) in a server I'm running? I want to do this
> before any connections are made from a client.
>
> Richard
>
The following code should do it.
You just have to provide the correct interface name.
struct sockaddr_in addr;
rtems_bsdnet_ifconfig("eth0", SIOCGIFADDR, &addr);
The IP address is then in addr.sin_addr.s_addr .
Best regards,
Thomas Rauscher
--
Dipl.-Ing. Thomas Rauscher Tel.: ++43 1 402 08 05 15
Fax: ++43 1 402 08 05 99
LOYTEC electronics GmbH E-mail: trauscher at loytec.com
Stolzenthalergasse 24/3, A-1080 Wien Web: http://www.loytec.com
More information about the users
mailing list