Re: [ros-users] Running Roscore without internet

Top Page
Attachments:
Message as email
+ (text/plain)
+ test.c (text/x-csrc)
Delete this message
Reply to this message
Author: Eric Perko
Date:  
To: ros-users
Subject: Re: [ros-users] Running Roscore without internet
Whoops.. forgot to attach the code (modified example from
http://en.wikipedia.org/wiki/Getaddrinfo). Also, this produces:

AF_INET family integer is: 2
AF_INET6 family integer is: 10
family for result was 2
hostname: localhost
family for result was 2
hostname: localhost
family for result was 2
hostname: localhost
family for result was 2
hostname: localhost
family for result was 2
hostname: localhost
family for result was 2
hostname: localhost

on my Ubuntu 9.10 machine.

- Eric

On Mon, May 10, 2010 at 7:00 PM, Eric Perko <> wrote:
> Alexis,
>
> What version of ROS and Ubuntu are you running?
>
> Also, could you try compiling and running the attached code? It uses a
> similar call to the place that generates that error regarding finding
> AF_INET addresses (comes from rosed xmlrpcpp XmlRpcSocket.cpp). I'm
> wondering what network addresses you actually have if you don't have
> AF_INET addresses for localhost when disconnected from the network...
>
> - Eric
>
> On Mon, May 10, 2010 at 6:34 PM, Ken Conley <> wrote:
>> Hi Alexis,
>>
>> Personally, I'm stumped. This doesn't appear to be just a ROS network
>> configuration issue. For some reason, your machine appears to be unable to
>> resolve localhost, which should work even when you're not connected. I'm not
>> aware of any reason why your ROS should work when you are plugged in versus
>> unplugged, if in both cases you are using 'localhost'. Is it the case that
>> you can ping localhost even when you're not connected?
>>
>>  - Ken
>>
>> On Mon, May 10, 2010 at 3:20 PM, Alexis Cheng <>
>> wrote:
>>>
>>> Hi Ken,
>>>
>>>
>>>
>>> I changed ROS_IP to 127.0.0.1, but the problem is persisting. Are there
>>> any steps/procedures to ensure the proper network configuration for
>>> ROS besides those outlined in the wiki?
>>>
>>>
>>>
>>> Thanks!
>>>
>>>
>>>
>>> Alexis Cheng
>>>
>>> Electrical Engineering
>>>
>>> University of British Columbia
>>>
>>>
>>> Hi Alexis,
>>>
>>> For some reason 'localhost' isn't resolving on your machine. I would
>>> recommend trying using
>>>
>>> ROS_IP=127.0.0.1
>>>
>>> instead of ROS_HOSTNAME=localhost. NOTE: this will disable your ability to
>>> connect to remote machines with ROS.
>>>
>>>  - Ken
>>>
>>>
>>> On Mon, May 10, 2010 at 3:09 PM, Alexis Cheng <>
>>> wrote:
>>>>
>>>> Hi all,
>>>>
>>>> I have installed ROS on a single Ubuntu machine and it seems to be
>>>> working while connected to the internet. However, roscore is unable to run
>>>> without internet connection. Roswtf does not return any errors or warnings.
>>>>
>>>> -----
>>>>
>>>> Roscore responds with:
>>>>
>>>> [ERROR] 1273528178.429037000: [registerService] Failed to contact master
>>>> at [localhost:11311]. Retrying...
>>>>
>>>> Rosrun responds with:
>>>>
>>>> Couldn't find an AF_INET address for [localhost]
>>>> [ERROR] 1273528740.753778000: [registerPublisher] Failed to contact
>>>> master at [localhost:11311]. Retrying...
>>>>
>>>> -----
>>>>
>>>> I have went through the network setup document on ROS wiki and it seems
>>>> to pass the tests. I have also changed ROS_HOSTNAME to localhost.
>>>>
>>>> Has anyone encountered this problem before and managed to correct it?
>>>>
>>>> Thanks!
>>>>
>>>> Alexis Cheng
>>>> Electrical Engineering
>>>> University of British Columbia
>>>>
>>>>
>>>> ________________________________
>>>> 30 days of prizes: Hotmail makes your day easier! Enter now
>>>> _______________________________________________
>>>> ros-users mailing list
>>>>
>>>> https://code.ros.org/mailman/listinfo/ros-users
>>>
>>> ________________________________
>>> Win a $10,000 shopping spree from Hotmail! Enter now Enter now
>>> _______________________________________________
>>> ros-users mailing list
>>>
>>> https://code.ros.org/mailman/listinfo/ros-users
>>>
>>
>>
>> _______________________________________________
>> ros-users mailing list
>>
>> https://code.ros.org/mailman/listinfo/ros-users
>>
>>
>

#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>

#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif

int main(void)
{
    struct addrinfo * result;
    struct addrinfo * res;
    int error;


    /* resolve the domain name into a list of addresses */
    error = getaddrinfo("localhost", NULL, NULL, &result);


    if (error != 0)
    {   
        fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
        return 1;
    }   


    printf("AF_INET family integer is: %d\nAF_INET6 family integer is: %d\n", AF_INET, AF_INET6);


    /* loop over all returned results and do inverse lookup */
    for (res = result; res != NULL; res = res->ai_next)
    {   
        char hostname[NI_MAXHOST] = "";


        error = getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST, NULL, 0, 0); 


        printf("family for result was %d\n", res->ai_family);


        if (error != 0)
        {
            fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
            continue;
        }


        if (*hostname)
        {
            printf("hostname: %s\n", hostname);
        }


    }   


    freeaddrinfo(result);


    return 0;
}