nanogui: Named Socket Binding and romfs


Previous by date: 9 May 2002 11:47:51 -0000 Re: Problem with touch screen, Pierre Tardy
Next by date: 9 May 2002 11:47:51 -0000 Re: IRQ's, Dan Malek
Previous in thread: 9 May 2002 11:47:51 -0000 Re: Named Socket Binding and romfs, Alex Holden
Next in thread:

Subject: Re: [nanogui] Named Socket Binding and romfs
From: Morten Rolland ####@####.####
Date: 9 May 2002 11:47:51 -0000
Message-Id: <1020944300.1349.2.camel@localhost.localdomain>

On Thu, 2002-05-09 at 01:26, Alex Holden wrote:
> Fabrice Gautier wrote:
> > So Is there any other solution I can use to connect client and server?
> 
> I wonder if we could use the abstract namespace feature of unix domain 
> sockets. Does anyone know how to generate a valid filename that is in 
> the abstract namespace?

I did the folowing recently:

void initialize_socket(char *name)
{
        struct sockaddr_un sa;
        int fd, sa_len, rc;

        fd = socket(PF_UNIX, SOCK_STREAM, 0);
        if ( fd < 0 )
                error...

        sa_len = setup_abst_address(&sa,name);

        rc = bind(fd,(struct sockaddr *)&sa,sa_len);
        if ( rc < 0 )
                error...

        listen etc..
}

Where the address is assigned like:

int setup_abst_address(struct sockaddr_un *sa, char *addr)
{
        char *a, *b;
        sa->sun_family = AF_UNIX;
        memset(sa->sun_path,0,sizeof(sa->sun_path));
        strcpy(&sa->sun_path[1],addr);
        a = (char *)sa;
        b = ((char *)&sa->sun_path[1]) + strlen(&sa->sun_path[1]);

        return b - a;
}

Where the name of the abstract socket can be "NanoX" or similar (Note
that it need not be a filename as suggested.  I think the address might
be totally binary as well like some other address families, but my
strcpy and strlen will terminate at the first \0).  When running strace
I think the address will come out as @NanoX to denote the abstract
namespace.

This is Linux specific, but might be implemented through a configure
option.

Regards,
Morten Rolland, Screen Media AS.



Previous by date: 9 May 2002 11:47:51 -0000 Re: Problem with touch screen, Pierre Tardy
Next by date: 9 May 2002 11:47:51 -0000 Re: IRQ's, Dan Malek
Previous in thread: 9 May 2002 11:47:51 -0000 Re: Named Socket Binding and romfs, Alex Holden
Next in thread:


Powered by ezmlm-browse 0.20.