Sponsored Content
Top Forums Programming How to get IP Address of machine? Post 39579 by Ahsan on Monday 25th of August 2003 01:23:49 AM
Old 08-25-2003
Question How to get IP Address of machine?

Is there any API call to get IP Address of a machine? I know there is function which returns name of the machine, gethostname(). But I need the IP.

Thanks & Regards,
Ahsan
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Changing Machine IP address

Hopefully someone can help with this. I need the command to change the IP address on a machine (7 Replies)
Discussion started by: kkinnon
7 Replies

2. UNIX for Dummies Questions & Answers

Restricting access to a machine by IP Address

I have a need to allow only certain IP addresses to access a machine running solaris 9. I am not sure how this can be accomplished. Thanks in advance for your help. Patch (2 Replies)
Discussion started by: patch
2 Replies

3. IP Networking

how to retrieve IP address of a machine

hi is there is any command that retrieves the IP address of a machine. Also is there any function in c that does the same. thankx (5 Replies)
Discussion started by: mridula
5 Replies

4. Shell Programming and Scripting

How to get Windows machine's IP address from Unix?

I am using windows Xp. From windows I would connect to my IBM AIX unix machine using telnet client. Is there any command available to view the IP address of Windows machine from Unix? (Note that ifconfig will give unix mahcine's IP address currently logged in.) (3 Replies)
Discussion started by: mvictorvijayan
3 Replies

5. UNIX for Advanced & Expert Users

IP address of machine

Hi i want to know the Ip address of the machine from where i logged into the unix server and made some changes to a file. Can I know the last changes made to a unix file ? (3 Replies)
Discussion started by: harneet2004us
3 Replies

6. UNIX for Dummies Questions & Answers

IP address of Unix machine

Can any one please tell me how to find the IP address of the Unix machine we are in? (9 Replies)
Discussion started by: thoothukudiking
9 Replies

7. Solaris

How to get the IP address / Host name of client machine

Hi How to get the IP address / Host name of a particular user connected to Unix Server. For example: If used 'DevUser1' is connected to Unix server. I need to find out from which PC this connection has been made. How can this be achieved? Thanks (6 Replies)
Discussion started by: MVL
6 Replies

8. UNIX for Dummies Questions & Answers

Static IP address for solaris 10 virtual machine

Hi All I am having a solaris 10 virtual machine on vista (using vmware 7) laptop. Now i want to access virtual machine from vista using putty. Problem is that i insalled the solaris machine as dhcp. and whenever i connect to internet or reboot my system the IP address of solaris... (1 Reply)
Discussion started by: ankurk
1 Replies

9. Solaris

i want to set ip address to a virtual machine

hi all i want to set ip address to a vitrual machine i am using following command. but it is not ifconfig -a command output. what is wrong i dont know bash# ifconfig interfacename plumb bash# ifconfig interfacename auto-dhcp Please use code tags next time for your code and data. (4 Replies)
Discussion started by: nikhil kasar
4 Replies

10. Programming

I.p address of machine

i m writing a program which finds the i.p address of the machine. but it just prints out the first three character of the ifconfig output but i want to just print my i.p address lik 10.0.0.222 which is in second line after inet addr: code : #include<iostream> #include<cstdlib> using... (1 Reply)
Discussion started by: console
1 Replies
gethostname(3C)                                            Standard C Library Functions                                            gethostname(3C)

NAME
gethostname, sethostname - get or set name of current host SYNOPSIS
#include <unistd.h> int gethostname(char *name, int namelen); int sethostname(char *name, int namelen); DESCRIPTION
The gethostname() function returns the standard host name for the current processor, as previously set by sethostname(). The namelen argu- ment specifies the size of the array pointed to by name. The returned name is null-terminated unless insufficient space is provided. The sethostname() function sets the name of the host machine to be name, which has length namelen. This call is restricted to the superuser and is normally used only when the system is bootstrapped. Host names are limited to MAXHOSTNAMELEN characters, currently 256, defined in the <netdb.h> header. RETURN VALUES
Upon successful completion, gethostname() and sethostname() return 0. Otherwise, they return -1 and set errno to indicate the error. ERRORS
The gethostname() and sethostname() functions will fail if: EFAULT The name or namelen argument gave an invalid address. The sethostname() function will fail if: EPERM The {PRIV_SYS_ADMIN} privilege was not asserted in the effective set of the calling process. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
sysinfo(2), uname(2), gethostid(3C), attributes(5), standards(5) SunOS 5.10 22 Mar 2004 gethostname(3C)
All times are GMT -4. The time now is 05:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy