Thread: 127.0.0.1

  1. #1
    Unregistered
    Guest

    127.0.0.1

    Hello,

    I am reading my first book on network programming. I have a single computer at home, running linux suse. My question is: Can I use address 127.0.0.1 to run my server and client programs or do I absolutely need two machines?

    Thanks

  2. #2
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195
    Are you asking if you can have a work station and a server on the same machine. If so the answer is yes.
    'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition

  3. #3
    Unregistered
    Guest

    hmm

    Not exactly, stautze. What I wonder is whether I can run both a server (say server.c) and its counterpart client (say client.c) on the same machine and make them communicate with each other.

    I am not interested in unix domain sockets (AF_UNIX or AF_LOCAL), but internet sockets.

  4. #4
    Unregistered
    Guest
    yes, you can...

  5. #5
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    clarity is here!

    Yes you can, first of all
    But it may depend

    What it would look like is this
    Server (127.0.0.1) -> Client (127.0.0.1) as long as Client supports the address 127.0.0.1, and I see no reason why it would not.

    if it is an internet communication you want then I would suggest setting up a masquerade or having the server run on 127.0.0.1 or whatever and have the client actually go through a DNS to your IP, like for example if my internet ip was 24.24.57.231 then I would do this:

    [Enter the server IP]: 24.24.57.231
    Connecting...
    Connection initiated.
    Enter command:

    etc.

    however if I did 127.0.0.1 then it would not go through a DNS or any loops just straight to itself not even touching the ethernet or modem card.
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >however if I did 127.0.0.1 then it would not go through a DNS or any loops just straight to itself not even touching the ethernet or modem card.
    .... which would be a far better thing, mostly if you have a firewall.

    If you are running a newly coded server, you really don't want it allowing incoming connections from the net. It is better to keep these things as local as possible until you are sure your code isn't going to allow someone unauthorised access to your system.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User
    Join Date
    May 2002
    Posts
    178
    Okay this thread really threw me off. How can you use 127.0.0.1 for an ip. That ip can't really be used as a network node address as it is reserved for the hardware loopback, correct? Or i could just be misunderstanding. Can someone clarify this please.
    Oi Oi Oi!!!!

  8. #8
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You can use it to connect to your own machine.

    If you run a telnet server, start a telnet client on the same box, and connect to 127.0.0.1 ....
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  9. #9
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    127.0.0.1 is just like any other adress except it starts with 127 and is the NATURAL default for a local address to the same machine like
    192.168.1.1 is a natural gateway address
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. This works fine with IP 127.0.0.1 but fails with my REAL IP.
    By azjherben in forum Networking/Device Communication
    Replies: 15
    Last Post: 05-19-2009, 10:28 PM
  2. Winsock Select() Function
    By PetrolMan in forum C++ Programming
    Replies: 10
    Last Post: 03-26-2009, 09:08 PM
  3. Network Blues
    By Cactus_Hugger in forum Tech Board
    Replies: 0
    Last Post: 09-14-2006, 07:02 PM
  4. popup bombarding
    By iain in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 07-11-2003, 08:02 AM
  5. Winsock working only for 127.0.0.1 Cant connect to other PCs
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 03-03-2002, 05:06 AM