repo.or.cz
/
python
/
dscho.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Added 'list_only' option (and modified 'run()' to respect it).
[python/dscho.git]
/
Demo
/
sockets
/
unixserver.py
blob
d4c706188f121c8af0d55dfd9e76cab31b1f8f4d
1
# Echo server demo using Unix sockets (handles one connection only)
2
# Piet van Oostrum
3
from
socket
import
*
4
FILE
=
'blabla'
5
s
=
socket
(
AF_UNIX
,
SOCK_STREAM
)
6
s
.
bind
(
FILE
)
7
print
'Sock name is: ['
+
s
.
getsockname
()+
']'
8
s
.
listen
(
1
)
9
conn
,
addr
=
s
.
accept
()
10
print
'Connected by'
,
addr
11
while
1
:
12
data
=
conn
.
recv
(
1024
)
13
if not
data
:
break
14
conn
.
send
(
data
)
15
conn
.
close
()