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
Feb 16 '07
15 7183
Kenneth Brody wrote:
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.
I'll add to the library:
char *GetMyIPv6() {
return "Not implemented";
}
Sorry. Couldn't resist.
In article <45************ ***@spamcop.net >,
Kenneth Brody <ke******@spamc op.netwrote:
....
>Of course, as has been pointed out, what happens if the machine has more than one IP address? What if it has none?
More to the point, "machines" don't have IP addresses. NICs do.
And, in many (most?) cases, the IP assigned to a given NIC isn't
the IP address that you care about anyway (because of NAT).
In article <er**********@n ews.xmission.co m>,
Kenny McCormack <ga*****@xmissi on.xmission.com wrote:
>More to the point, "machines" don't have IP addresses. NICs do.
NICs only need to read and write packets; everything else is up to
the IP stack or is an optimization with the cooperation of the IP
stack.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Clever Monkey wrote:
>
Kenneth Brody wrote:
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.
I'll add to the library:
char *GetMyIPv6() {
return "Not implemented";
}
Sorry. Couldn't resist.
Shouldn't that be "return NULL;" to indicate an error? :-)
--
+-------------------------+--------------------+-----------------------+
| 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>
>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.
*THE* IP address? Isn't that a little like telling someone to press
*THE* key on *THE* keyboard?
Assuming it's got networking and TCP/IP, "127.0.0.1" is a surprisingly
portable answer to this question.
On Fri, 16 Feb 2007 05:16:18 -0600, sunny wrote
(in article <11************ **********@h3g2 000cwc.googlegr oups.com>):
i need to write a c program to get the ip of my own machine without
using the sockets in it.
As others have indicated, and you have snipped away the context, this
is tricky to do, and outside the scope of this particular newsgroup.
You should ask in a newsgroup appropriate to your platform, and keep in
mind that doing this correctly can be tricky, especially with systems
with more than one network adapter.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw 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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |