473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

ip address

using c program
how to get the ip address of
the system

Mar 22 '06 #1
10 7080
somu wrote:
using c program
how to get the ip address of
the system


By calling a implementation/platform specific API. Ask in a group
appropriate to your OS.

Mar 22 '06 #2
"santosh" <sa*********@gmail.com> wrote:
somu wrote:
using c program
how to get the ip address of
the system


By calling a implementation/platform specific API. Ask in a group
appropriate to your OS.


Also consider that for many architectures, there is no single, definite
answer to your question - and under some circumstances, there may be
none at all.

Richard
Mar 22 '06 #3
somu wrote:
using c program
how to get the ip address of
the system


Use some system specific library. Since we don't discuss system specific
libraries here you will have to ask on a group dedicated to your system
or to networking.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Mar 22 '06 #4
somu wrote:
using c program
how to get the ip address of
the system

it depends on your
platform; find a dedicated group,
ask there

S.
Mar 22 '06 #5
I think u have modify the statement in the system functionl according to the display of ifconfig on ur machine.

#include<stdio.h>
#include<unistd.h>
#include<fstream.h>
#include<sys/stat.h>
#include<iostream>

using namespace std;

main()

{
char i,j;
ifstream fin("ip.out");
if (!fin)
system("ifconfig -a | grep inet| tail -1 | awk '{ print $2 }'>> ip.out");
while (fin)
{
fin.get(i);
j=i;
cout<<j;
}
fin.close();
}
Apr 24 '06 #6
If there is any query plz tell me know
Apr 24 '06 #7
mmk622
4
Hi mine is a peculiar problem, but similar to the one "using c program
how to get the ip address of the system"

I am having three ethernet card in my system
eth0
eth1
ppp0

My task is to retrieve the ip address in ppp0 .How to write a c pgm to achieve this ..
please help ....mmk622@yahoo.co.in
Apr 28 '06 #8
Hi mine is a peculiar problem, but similar to the one "using c program
how to get the ip address of the system"

I am having three ethernet card in my system
eth0
eth1
ppp0

My task is to retrieve the ip address in ppp0 .How to write a c pgm to achieve this ..
please help ....mmk622@yahoo.co.in

My suggestion is modify the ifconfig -a command written in system call according to ur system. remain all as it is.It will work.
Apr 28 '06 #9
mmk622
4
Hi yogesh,
how to modify ifconfig -a command...which system call i have to see. I have tried above program but its giving errors. If you have another snippet of code please send me.
bye
Murali
Apr 28 '06 #10
mmk622
4
1) Here i am trying to establish ppp connection between two systems and i have to transfer a file through modem.
2) There will be two systems with modems.
3) I will dail from one system to another.
4) Suppose we dail from client to server.
5)After dailing server lifts the call automatically and assign some ip address ppp0 to client.which we can see typing ifconfig -a in client.
5) Using that ip we will connect using tcp/ip sockets gethostbyname(server_addr) to server and transfer file.
Here i am able to transfer the file using gethostbyname(20.0.0.1) where 20.0.0.1 is the ip address which i used in server configuration. This may warry depends on server.So i need to write a c code to retrieve the ip address from ifconfig -a. The code which you have provided above is not working with my compiler . Some fstream.h not found and many errors are araising.
So, i need your help. Please send me the code which should read ifconfig -a into a file and trace ppp0 inet addr
Thank you,
Murali
Apr 28 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Alexander N. Spitzer | last post by:
If I have a machine with 3 virtual IP addresses (192.168.1.), how can I start 3 instances of the same RMI application (each started with different properties/configs), each listening on the port...
8
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: ...
7
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
33
by: baumann.Pan | last post by:
hi all, i want to get the address of buf, which defined as char buf = "abcde"; so can call strsep(address of buf, pointer to token);
4
by: andreas.w.h.k. :-\) | last post by:
How do I change the address location in the wsdl <wsdl:port name="SearchSoap12" binding="tns:SearchSoap12"> <soap12:address location="http://searchservices/engine/search.asmx" /> </wsdl:port> ...
1
by: Phoenix_ver10 | last post by:
I have a mailing list with multiple names going to the same addresses. I need one address with all the names for that address on it. I checked out the example on microsoft's site, but A: It doesn't...
1
by: Jamie J. Begin | last post by:
I'm very new to the world of Python and am trying to wrap my head around it's OOP model. Much of my OOP experience comes from VB.Net, which is very different. Let's say I wanted to create an...
6
by: Nicolas Noakes | last post by:
Hello, I would like to convert to following process to code. Any advice is welcome. I have a hardware device which requires the this procedure to set it's IP address. First create an static...
36
by: Julienne Walker | last post by:
Ignoring implementation details and strictly following the C99 standard in terms of semantics, is there anything fundamentally flawed with describing the use of a (non-inline) function as an...
1
by: saravanatmm | last post by:
I need javascript code for validate the email address. Email address field cannot allowed the capital letters, special characters except '@' symbol. But can allowed the small letters, numeric...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.