Subject: [clisp-list] How to open a UNIX socket with clisp?

From: Peter Van Eynde <[email-masked]>
Date: Tue Oct 23 12:04:37 2001

Hi,

I'm trying to port clocc-port unix sockets to clisp and I don't find how
to open a non-internet socket with clisp. In concrete I would like to
open /tmp/.X11-unix/X0 so CLX can connect to the X server. (Recent
debian distributions don't listen anymore on port 6000 for security
reasons so I have to use UNIX sockets).

Please tell me I've missed an obvious function :-)

Groetjes, Peter

-- 
It's logic Jim, but not as we know it. | [email-masked]
"God, root, what is difference?" - Pitr|
"God is more forgiving." - Dave Aronson| http://cvs2.cons.org/~pvaneynd/

---

From: Sam Steingold <[email-masked]>
Date: Tue Oct 23 13:15:07 2001

> * In message <20011023205357.A20148@localhost>
> * On the subject of "[clisp-list] How to open a UNIX socket with clisp?"
> * Sent on Tue, 23 Oct 2001 20:53:57 +0200
> * Honorable Peter Van Eynde <[email-masked]> writes:
>

does (open :direction :io) work?

-- 
Sam Steingold (http://www.podval.org/~sds)
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
I'd give my right arm to be ambidextrous.

---

From: Erik Arneson <[email-masked]>
Date: Tue Oct 23 13:37:09 2001

> does (open :direction :io) work?

That works just fine for FIFOs, but I'm not sure that will work very
well for UNIX domain sockets.  Normally in C you use similar socket
calls with a socket type of PF_UNIX instead of PF_INET.

See 'man 7 unix' for more about these kinds of sockets.  It doesn't look
like CLISP supports these yet?

-- 
# Erik Arneson <[email-masked]>    AARG Net <http://www.aarg.net/> #
# GPG Key ID: 1024D/43AD6AB8           <http://erik.arneson.org/> #
# "Resistance to tyrants is obedience to God!" - Thomas Jefferson #

---

From: Sam Steingold <[email-masked]>
Date: Tue Oct 23 14:08:07 2001

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] How to open a UNIX socket with clisp?"
> * Sent on Tue, 23 Oct 2001 13:36:20 -0700
> * Honorable Erik Arneson <[email-masked]> writes:
>

(sys::make-socket-stream host display)
has been added specifically for mit-clx.
when host is a length 0 string, a unix socket pointing to a standard X
socket is returned.

> calls with a socket type of PF_UNIX instead of PF_INET.

open can be made to work with them, right?

how do I create a unix socket from the shell?
(mknod(1) on solaris does not mention this).
how do I determine that a file "/foo/bar" is actually a unix socket?
(fstat(3) and mknod(2) on solaris do not mention unix sockets).

-- 
Sam Steingold (http://www.podval.org/~sds)
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Those who value Life above Freedom are destined to lose both.

---

From: Erik Arneson <[email-masked]>
Date: Tue Oct 23 14:20:01 2001

> open can be made to work with them, right?

I don't think open works with any sort of socket.  PF_UNIX sockets are
treated very much like PF_INET sockets wherever possible.  In other
words, you have to bind them and use the normal libc socket interface.

> (fstat(3) and mknod(2) on solaris do not mention unix sockets).

You can't create a UNIX socket from the shell, as far as I know.  You
can't interface with them normally via 'cat' and such, either, like you
can with a FIFO.  They're quite a pain in the butt, huh?  :)

---

From: Sam Steingold <[email-masked]>
Date: Tue Oct 23 14:37:01 2001

> * In message <[email-masked]>
> * Sent on Tue, 23 Oct 2001 14:18:33 -0700

I meant CL OPEN, not UNIX fopen(2).

> can't interface with them normally via 'cat' and such, either, like
> you can with a FIFO.  They're quite a pain in the butt, huh?  :)

ouch...

at any rate, unless someone tells me how do I know whether "/foo/bar" is
a socket, there is nothing I could do.

-- 
Sam Steingold (http://www.podval.org/~sds)
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
If it has syntax, it isn't user friendly.

---

From: Raymond Toy <[email-masked]>
Date: Tue Oct 23 14:47:05 2001

>>>>> "Sam" == Sam Steingold <[email-masked]> writes:

    >> you can with a FIFO.  They're quite a pain in the butt, huh?  :)

    Sam> ouch...

    Sam> at any rate, unless someone tells me how do I know whether "/foo/bar" is
    Sam> a socket, there is nothing I could do.

On Solaris, there's a S_ISSOCK (see stat(5)).  I assume this is how ls
knows that /tmp/.X11-unix/X0 is a socket and prints a = after it.

Ray

---

From: Sam Steingold <[email-masked]>
Date: Tue Oct 23 15:05:07 2001

> * In message <[email-masked]>
> * Sent on 23 Oct 2001 17:46:36 -0400
> * Honorable Raymond Toy <[email-masked]> writes:
>

nope, not on Solaris 2.5.1.

Live Lisp and prosper.

---

From: Erik Arneson <[email-masked]>
Date: Tue Oct 23 16:04:05 2001

> knows that /tmp/.X11-unix/X0 is a socket and prints a = after it.

Linux has this as well.

I see this on our Solaris boxen, too.  I wonder what version they added
it?

---

From: Raymond Toy <[email-masked]>
Date: Wed Oct 24 05:44:08 2001

>> knows that /tmp/.X11-unix/X0 is a socket and prints a = after it.

    Sam> nope, not on Solaris 2.5.1.

Ok, I'm on 2.7.  Anyway, here's the definition from sys/stat.h:

#define S_ISSOCK(mode)  (((mode)&0xF000) == 0xc000)

Ray

---

From: Peter Van Eynde <[email-masked]>
Date: Wed Oct 24 14:51:08 2001

> when host is a length 0 string, a unix socket pointing to a standard X

Thanks. That sort-of solves my problem. Except for the :: part :-).

Can I use this as a 'supported' interface?

Groetjes, Peter

---

From: Sam Steingold <[email-masked]>
Date: Thu Oct 25 06:29:01 2001

> * In message <20011024234958.A18778@localhost>
> * Sent on Wed, 24 Oct 2001 23:49:58 +0200

yes - CLX is its raison d'etre.

-- 
Sam Steingold (http://www.podval.org/~sds)
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Flying is not dangerous; crashing is.