IP adress in Linux?

This is a discussion on IP adress in Linux? within the Linux Programming forums, part of the Platform Specific Boards category; Well I have 2 questions! 1. How do I find out the IP adress of the PC I'm will run ...

  1. #1
    IM!
    IM! is offline
    Freak! IM!'s Avatar
    Join Date
    Dec 2004
    Location
    Zagreb, Croatia
    Posts
    30

    IP adress in Linux?

    Well I have 2 questions!
    1. How do I find out the IP adress of the PC I'm will run the program I'm trying to write? Can anyone post the code?
    2. In windows there are these apps who work in the background in the taskbar, has Linux a smiliar thing, any tutorials?

  2. #2
    Registered User Scribbler's Avatar
    Join Date
    Sep 2004
    Location
    Aurora CO
    Posts
    266
    As root, type ifconfig into a console terminal.

    Alternatively, depending on which windows/desktop environment you're using there are various tools which will display this information. Gnome has Network Tools in the System Tools menu. KDE's Control Center usually displays that information when executed.
    Last edited by Scribbler; 02-27-2005 at 09:36 AM.

  3. #3
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    >>2. In windows there are these apps who work in the background in the taskbar, has Linux a smiliar thing, any tutorials?

    you mean automatically or when it is run?
    if you want to background an application add a & to th end of the command
    eg:

    root@darkstar#: myprogram &
    Monday - what a way to spend a seventh of your life

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Quote Originally Posted by Scribbler
    As root, type ifconfig into a console terminal.

    Alternatively, depending on which windows/desktop environment you're using there are various tools which will display this information. Gnome has Network Tools in the System Tools menu. KDE's Control Center usually displays that information when executed.

    What I think he is trying to get at is how to do it inside a program, which means he should probably learn something about sockets.

    Also, in *nix most background programs that run without user input are called Daemons.

    My only thought is why did the thread starter ask both of these questions? If we could get some more input it might help us out too.


    EDIT: Just check out some of his previous postings, looks like he is trying to send data over the net, just needs to learn how. I would suggest looking into Socket programming, and their are some good libraries out there that help with that. The one I have currenlty been looking into is called ACE You can check it out here.
    Last edited by Xipher; 02-27-2005 at 01:47 PM.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  5. #5
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    An excellent socket reference
    http://www.ecst.csuchico.edu/~beej/guide/net/

    >>How do I find out the IP adress of the PC I'm will run the program I'm trying to write? Can anyone post the code?

    if you can let us have a few more specific details on what you are trying to achieve we will be able to give you more specific help
    Monday - what a way to spend a seventh of your life

  6. #6
    IM!
    IM! is offline
    Freak! IM!'s Avatar
    Join Date
    Dec 2004
    Location
    Zagreb, Croatia
    Posts
    30

    Smile

    Wow people I'm really happy about the interest, sorry It took so long! Well what i want to get is a programm that would run as a Daemon, it would get my IP adress periodicly every 2 hours and compare it with the previous recoreded one! If they aren't the same he would send this IP number to a DynDNS service. I know there are probably many of these progs but i wanted to learn something about this topic!

  7. #7
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,257
    gethostname() , then gethostbyname() . Call those two functions to get the ip address.

  8. #8
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Quote Originally Posted by IM!
    Wow people I'm really happy about the interest, sorry It took so long! Well what i want to get is a programm that would run as a Daemon, it would get my IP adress periodicly every 2 hours and compare it with the previous recoreded one! If they aren't the same he would send this IP number to a DynDNS service. I know there are probably many of these progs but i wanted to learn something about this topic!
    Ok, that does help a bit. You also might want to be able to specify which interface to pool when you get into it some more, as some hosts (router maybe) will have more then one interface. I don't have my books with me though to look up how its normally done.

    Quote Originally Posted by bithub
    gethostname() , then gethostbyname() . Call those two functions to get the ip address.
    That will only work if your hostname is either in the hosts file, and set to your ip, or is registered with the DNS servers you use. It wouldn't be uncommon for niether of these to be the case.
    Last edited by Xipher; 02-27-2005 at 04:58 PM.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 32 bit binary IP to decimal IP (vice-versa)
    By Mankthetank19 in forum C Programming
    Replies: 15
    Last Post: 12-28-2009, 07:17 PM
  2. how to get local ip adress
    By wwwnuwan in forum Networking/Device Communication
    Replies: 12
    Last Post: 03-31-2009, 09:07 AM
  3. How to read IP Adress!
    By Smoki in forum C++ Programming
    Replies: 2
    Last Post: 12-02-2005, 06:56 AM
  4. Finding IP adress
    By acidbeat311 in forum C Programming
    Replies: 4
    Last Post: 05-24-2005, 09:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21