Hai,
Anybody can give me idea how to get the ip address of my machine
through a cprogram with out using the socket programming. Is there any
system call to get the ip address of my machine that will be used in
the c program to display the IP address of my machine.
Regards,
Sunny 15 7181
sunny wrote:
Anybody can give me idea how to get the ip address of my machine
through a cprogram with out using the socket programming. Is there any
system call to get the ip address of my machine that will be used in
the c program to display the IP address of my machine.
There's no such function in standard C. For portability I'd guess something
POSIXy, so asking in comp.unix.progr ammer might help (even if you're
/not/ on a Unix box).
--
Chris "electric hedgehog" Dollin
"No-one here is exactly what he appears." G'kar, /Babylon 5/
In article <er**********@m urdoch.hpl.hp.c om>,
Chris Dollin <ch**********@h p.comwrote:
>sunny wrote:
>Anybody can give me idea how to get the ip address of my machine through a cprogram with out using the socket programming. Is there any system call to get the ip address of my machine that will be used in the c program to display the IP address of my machine.
There's no such function in standard C. For portability I'd guess something POSIXy, so asking in comp.unix.progr ammer might help (even if you're /not/ on a Unix box).
IOW:
Off topic. Not portable. Cant discuss it here. Blah, blah, blah.
Useful clc-related links: http://en.wikipedia.org/wiki/Aspergers http://en.wikipedia.org/wiki/Clique http://en.wikipedia.org/wiki/C_programming_language
In article <er**********@m urdoch.hpl.hp.c om>,
Chris Dollin <ch**********@h p.comwrote:
>Anybody can give me idea how to get the ip address of my machine through a cprogram with out using the socket programming. Is there any system call to get the ip address of my machine that will be used in the c program to display the IP address of my machine.
>There's no such function in standard C.
And since a computer can easily have several IP addresses (or none),
you might want to consider what exactly you want.
-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
i need to write a c program to get the ip of my own machine without
using the sockets in it.
In article <11************ **********@h3g2 000cwc.googlegr oups.com>,
sunny <ka************ ***@gmail.comwr ote:
>i need to write a c program to get the ip of my own machine without using the sockets in it.
But why? What should the program do if the machine hasn't got an IP
address, or has several?
And as you've been told, there's no way to do it in standard C; you'll
need to ask in a group that deals with your particular operating
system. There may be a function that returns all the IP addresses
associated with your machine, or perhaps something that tells you the
name (or one of the names) of your machine, and a function that lets
you look up the IP address(es) assocument with that name.
-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
sunny wrote:
i need to write a c program to get the ip of my own machine without
using the sockets in it.
Please quote the post you're replying to.
The standrad C language has no facility to do what you want. You'll
probably have to call a POSIX function like gethostname() or
gethostid(). Please look it up in your system's documentation or take
this question to whatever group that is more specific to your
platform. For example, if you're on a UNIX, post to
comp.unix.progr ammer.
Richard Tobin wrote:
In article <er**********@m urdoch.hpl.hp.c om>,
Chris Dollin <ch**********@h p.comwrote:
>>Anybody can give me idea how to get the ip address of my machine through a cprogram with out using the socket programming. Is there any system call to get the ip address of my machine that will be used in the c program to display the IP address of my machine.
>>There's no such function in standard C.
And since a computer can easily have several IP addresses (or none),
you might want to consider what exactly you want.
-- Richard
And amusingly on top of that, the procedure used to discover the assigned IPs
to each interface on a host is neither POSIX compliant nor standard. About
the most "portable" way is using ioctl's which are system specific and hoping
that the system you're on supports the more "standard" ioctl's.
It pretty much sucks but is documented in UNPv1 (Stevens).
In article <er***********@ pc-news.cogsci.ed. ac.uk>,
Richard Tobin <ri*****@cogsci .ed.ac.ukwrote:
>In article <11************ **********@h3g2 000cwc.googlegr oups.com>, sunny <ka************ ***@gmail.comwr ote:
>>i need to write a c program to get the ip of my own machine without using the sockets in it.
But why? What should the program do if the machine hasn't got an IP address, or has several?
And as you've been told, there's no way to do it in standard C; you'll need to ask in a group that deals with your particular operating system. There may be a function that returns all the IP addresses associated with your machine, or perhaps something that tells you the name (or one of the names) of your machine, and a function that lets you look up the IP address(es) assocument with that name.
IOW:
Off topic. Not portable. Cant discuss it here. Blah, blah, blah.
Useful clc-related links: http://en.wikipedia.org/wiki/Aspergers http://en.wikipedia.org/wiki/Clique http://en.wikipedia.org/wiki/C_programming_language
sunny wrote:
>
i need to write a c program to get the ip of my own machine without
using the sockets in it.
You can't do this in standard C. The closest you can do is:
char *GetMyIP()
{
return "127.0.0.1" ;
}
However, I doubt this is sufficient for what you need/want.
There are "standard" function calls, outside the scope of standard C,
which you can use. Perhaps something like gethostid()? However, to
get more details, you need to ask elsewhere. Perhaps this is topical
in comp.unix.progr ammer?
Of course, as has been pointed out, what happens if the machine has
more than one IP address? What if it has none?
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Arne |
last post by:
Hi,
Probably an easy answer to this, but I have not been able to figure it out.
How can I find the IP-address of the machine that my Java-program is running
on ? Could not find any methods in the InetAddress class that does this. The
closest I got was the getLocalHost() which will return the IP-address
representing the loopback address (usually 127.0.01, isn't it ?).
Any ideas ?
|
by: YAN |
last post by:
Hi,
I want to get the mac address from a machine, which i have the IP address of
that machine, how can i do that?
I know how to get the mac address of the local machine from the following
code:
Dim mc As System.Management.ManagementClass
Dim mo As System.Management.ManagementObject
mc = New
System.Management.ManagementClass("Win32_NetworkAdapterConfiguration")
|
by: MLH |
last post by:
Would like to roll out something in Access 2.0 to read MAC
address on 16-bit systems. Have resolved on 32-bit platforms
but still need help with Access Basic code to do it from within
Access 2.0.
|
by: candy |
last post by:
hi all,
Is there is any way in the C language by which I can get the
address of a statement? For eg,consider the following simple program:
1. #include<stdio.h>
2.
3. int main(void){
4. int variable;
|
by: Terry Petty |
last post by:
I want to write a program that gets the leased IP address off of my DSL
router and then tells a remote machine what that address is so that machine
can find it.
The remote machine on the web with a fixed IP will have a page with a link
to a video camera that is located on a closed internal network. That network
gateway is a DSL router and the camera is behind that proxy server. When the
leased address changes, the program will report to...
| |
by: rdonnici |
last post by:
Hi all,
Is there any way to, given an IP address(or NETBIOS machinename - I can
convert from one to other) from my network, and assuming that everyone
needs to log on a NT/2K/Windows Server 2003 Server, to discover the
user name for the user logged on that machine? The final result
desired is something like a table, with pairs at the moment the program is run.
Any ideas? I have hunted high and low on the newsgroups and have not...
|
by: rs |
last post by:
Hello everyone,
Is it possible to get the IP address of a machine on the network if we
know the windows login name. I am assuming NO. If anyone knows a work
around or how this can be done, please let me know
|
by: elvira_wang |
last post by:
heya,
what sort of address is displayed when this instruction for instance is
executed
printf("myvar location is 0x%lx\n", (long) &myvar);
is it logical address or linear address, i.e. with logical address i
mean
segment number | relative address within the segment, whereas with
linear address i mean
|
by: polas |
last post by:
Hi everyone - I have a question. I am just playing around with C (I
realise there are better ways to do what I want, but I would like to
do it this way to increase my understanding of C) and would like to
read an executable file in to a portion of memory and then pass
execution to this and execute the file. However, I can not get it
working and my efforts have resulted in a Seg Fault.
Below is the code I have got
#include "stdio.h"
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |