By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,581 Members | 1,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,581 IT Pros & Developers. It's quick & easy.

"Socket" files?

P: n/a
How are those "files" of type "socket", whose name
begins with "=", created? How can I create them with
python?

Thanks.
Jul 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a

On Fri, Aug 20, 2004 at 09:58:43PM +0100, Paulo da Silva wrote:
How are those "files" of type "socket", whose name
begins with "=", created? How can I create them with
python?


they don't start w/ =; that's just ls being verbose. try 'ls -1'.

you can create them with os.mkfifo. see lib doc, section 6.1.4.
Jul 18 '05 #2

P: n/a
Marcos Dione wrote:
On Fri, Aug 20, 2004 at 09:58:43PM +0100, Paulo da Silva wrote:
How are those "files" of type "socket", whose name
begins with "=", created? How can I create them with
python?

they don't start w/ =; that's just ls being verbose. try 'ls -1'.

you can create them with os.mkfifo. see lib doc, section 6.1.4.


mkfifo creates fifo nodes, not "socket"-type files.
I think Unix domain sockets are what the OP means...
Which are created by using the AF_UNIX socket type:

from socket import *
sock=socket(AF_UNIX,SOCK_STREAM)
sock.bind("/tmp/mysocket")

BTW, my ls lists them in pink, with a '=' at *the end*.
That's on Mandrake 10.

--Irmen

Jul 18 '05 #3

P: n/a
Marcos Dione wrote:
....

they don't start w/ =; that's just ls being verbose. try 'ls -1'.

you can create them with os.mkfifo. see lib doc, section 6.1.4.


This seems to work. At least ls gives the same result.
Thank you.
Jul 18 '05 #4

P: n/a
Irmen de Jong wrote:
Marcos Dione wrote:
....

mkfifo creates fifo nodes, not "socket"-type files.
I think Unix domain sockets are what the OP means...
Which are created by using the AF_UNIX socket type:

from socket import *
sock=socket(AF_UNIX,SOCK_STREAM)
sock.bind("/tmp/mysocket")

....
This seems more logical. Besides there is also a "file" type
"fifo" where I was using mkfifo.

I'll give it a try. Unfortunately I began to upgrade my Gentoo
Linux and I am busy now.

Thank you.
Jul 18 '05 #5

P: n/a
Paulo da Silva wrote:
Irmen de Jong wrote:
Marcos Dione wrote:

...
....
from socket import *
sock=socket(AF_UNIX,SOCK_STREAM)
sock.bind("/tmp/mysocket")


...
This seems more logical. Besides there is also a "file" type
"fifo" where I was using mkfifo.

I'll give it a try. Unfortunately I began to upgrade my Gentoo
Linux and I am busy now.


OK. It works! I'll use mkfifo for "fifo" type and this for
"socket" type.
BTW, don't I need to close "sock.close()"? I don't want to
do anything with the socket except keeping it on disk.
Jul 18 '05 #6

P: n/a
Paulo da Silva <ps*********@esotericax.ptx> wrote:
Irmen de Jong wrote:
from socket import *
sock=socket(AF_UNIX,SOCK_STREAM)
sock.bind("/tmp/mysocket")

[...]

OK. It works! I'll use mkfifo for "fifo" type and this for
"socket" type.
BTW, don't I need to close "sock.close()"? I don't want to
do anything with the socket except keeping it on disk.


Uhm, are you sure you know what you're doing? UNIX domain
sockets work very similar to Internet domain sockets, i.e.
they disappear when they're closed (or when your program
exits, in which case everything is closed implicitly).

Why exactly do you want to create one and keep it on disk
without doing anything with it? That doesn't seem make any
sense at all.

Best regards
Oliver

--
Oliver Fromme, Konrad-Celtis-Str. 72, 81369 Munich, Germany

``All that we see or seem is just a dream within a dream.''
(E. A. Poe)
Jul 18 '05 #7

P: n/a
Oliver Fromme wrote:
Paulo da Silva <ps*********@esotericax.ptx> wrote: ....
Why exactly do you want to create one and keep it on disk
without doing anything with it? That doesn't seem make any
sense at all.

Well, I never programmed anything using fifo or sockets.
What I need to do as part of a work is to get information
about some disk or a dir contents and then replicate it
later (something like a backup). I don't really know if
those "files" of type socket have any other role behind
sockets communication. So I thought of replicate them also.
I have seen that tar doesn't seem to "save" them, but cp does.
BTW, those "files" are kept after issuing close().

Thank you for your comments on this.
Jul 18 '05 #8

P: n/a
Oliver Fromme wrote:

Uhm, are you sure you know what you're doing? UNIX domain
sockets work very similar to Internet domain sockets, i.e.
they disappear when they're closed (or when your program
exits, in which case everything is closed implicitly).


Indeed. Last time I played with Unix-domain sockets (which
was quite some time ago, things may have changed since)
the entry in the file system seemed to be completely
useless -- you couldn't do anything with it that you
might expect, e.g. open() it. The docs described the fact
that a file system entry existed as a "side effect" that
might go away in future versions.

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg

Jul 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.