Sponsored Content
Full Discussion: Get ip address
Top Forums Programming Get ip address Post 20345 by chkim on Thursday 25th of April 2002 12:51:50 AM
Old 04-25-2002
Get ip address

Hi
I am trying to get IP address of of my Irix server from my C program running on the host machine.
------------------------------------------------

#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>

main()
{
struct in_addr ia;
printf("host id %u\n", gethostid());
ia.s_addr = htonl(gethostid());
printf("My address: %s\n", inet_ntoa(ia));
exit(0);
}

--------------------------------------------------------------------

result
# a.out
host id 3555268269
My address: 255.255.255.255

__________________________________________
result is incorrect. help me plz..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

network address and broadcast address?

say I have a IP address which is 10.0.0.12, and subnet mask is 255.255.255.240, what is the network address and what is the broadcast address which host lives on? And could you explain how to get the answer? thanx in advance! (7 Replies)
Discussion started by: pnxi
7 Replies

2. IP Networking

How to Achive IP address through MAC(Ethernet) address

Hi sir, i want to make such programe which takes MAC(Ethernet) address of any host & give me its IP address....... but i'm nt getting that how i can pass the MAC address to Frame........ Please give me an idea for making such program... Thanks & regards Krishna (3 Replies)
Discussion started by: krishnacins
3 Replies

3. Shell Programming and Scripting

ksh - how to list all ip address between 2 ip address

Trying to do a ksh script that needs to list all ip address between ip address a and b .. ie. Ip address A=192.168.1.200 Ip address B=192.168.2.15 So the subnet changes from 1 to 2 but I want to list all possible ip addresses between the 2.. Which would be: 192.168.1.200... (4 Replies)
Discussion started by: frustrated1
4 Replies

4. UNIX for Dummies Questions & Answers

Panic kernal-mode address fault on user address 0x14

:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message: PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14 KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD) EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies

5. Solaris

Get ip address from mac address

I have following message in my messages file on solaris 10 WARNING: e1000g3712000:3 has duplicate address 010.022.196.011 (in use by 00:50:56:85:25:ef); disabled Now is there any way i can find which server has 00:50:56:85:25:ef mac address either IP or Hostname ? (6 Replies)
Discussion started by: fugitive
6 Replies

6. UNIX for Dummies Questions & Answers

What would the physical address be for virtual address?

Hi guys, I got one problem which I definetily no idea. What would the physical address be for virtual address? 1) 2ABC 2) 3F4B Here is the page table:see attached Thank you sos sososososso much!! (0 Replies)
Discussion started by: lemon_06
0 Replies

7. IP Networking

Tracing a MAC address to IP address: Solaris

Hi there I lost connectivity to one of our remote systems and when I checked the messages log I found the following: Aug 10 23:42:34 host xntpd: time reset (step) 1.681729 s Aug 16 13:20:51 host ip: WARNING: node "mac address" is using our IP address x.x.x.x on aggr1 Aug 16 13:20:51 host... (9 Replies)
Discussion started by: notreallyhere
9 Replies

8. UNIX for Advanced & Expert Users

C program to detect duplicate ip address if any after assigning ip address to ethernet interface

Hi , Could someone let me know how to detect duplicate ip address after assigning ip address to ethernet interface using c program (3 Replies)
Discussion started by: Gopi Krishna P
3 Replies

9. IP Networking

MAC Address - Four Interfaces with the same MAC Address

four interfaces with ifconfig all interfaces have the same mac. If is not set for unique. but it still works. what difference does it make to have all macs the same or different? (4 Replies)
Discussion started by: rrodgers
4 Replies
INET(3) 						     Linux Programmer's Manual							   INET(3)

NAME
inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof - Internet address manipulation routines SYNOPSIS
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int inet_aton(const char *cp, struct in_addr *inp); in_addr_t inet_addr(const char *cp); in_addr_t inet_network(const char *cp); char *inet_ntoa(struct in_addr in); struct in_addr inet_makeaddr(int net, int host); in_addr_t inet_lnaof(struct in_addr in); in_addr_t inet_netof(struct in_addr in); DESCRIPTION
inet_aton() converts the Internet host address cp from the standard numbers-and-dots notation into binary data and stores it in the struc- ture that inp points to. inet_aton returns nonzero if the address is valid, zero if not. The inet_addr() function converts the Internet host address cp from numbers-and-dots notation into binary data in network byte order. If the input is invalid, INADDR_NONE (usually -1) is returned. This is an obsolete interface to inet_aton, described immediately above; it is obsolete because -1 is a valid address (255.255.255.255), and inet_aton provides a cleaner way to indicate error return. The inet_network() function extracts the network number in host byte order from the address cp in numbers-and-dots notation. If the input is invalid, -1 is returned. The inet_ntoa() function converts the Internet host address in given in network byte order to a string in standard numbers-and-dots nota- tion. The string is returned in a statically allocated buffer, which subsequent calls will overwrite. The inet_makeaddr() function makes an Internet host address in network byte order by combining the network number net with the local address host in network net, both in local host byte order. The inet_lnaof() function returns the local host address part of the Internet address in. The local host address is returned in local host byte order. The inet_netof() function returns the network number part of the Internet Address in. The network number is returned in local host byte order. The structure in_addr as used in inet_ntoa(), inet_makeaddr(), inet_lnoaf() and inet_netof() is defined in netinet/in.h as: struct in_addr { unsigned long int s_addr; } Note that on the i80x86 the host byte order is Least Significant Byte first, whereas the network byte order, as used on the Internet, is Most Significant Byte first. CONFORMING TO
BSD 4.3 SEE ALSO
gethostbyname(3), getnetent(3), inet_ntop(3), inet_pton(3), hosts(5), networks(5) BSD
2001-07-25 INET(3)
All times are GMT -4. The time now is 10:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy