~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to sandbox/exarkun/copyover/stupid_server.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2004-06-21 22:01:11 UTC
  • mto: (2.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040621220111-vkf909euqnyrp3nr
Tags: upstream-1.3.0
ImportĀ upstreamĀ versionĀ 1.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os, sys
 
2
from socket import * # har har har
 
3
from tempfile import TemporaryFile
 
4
sys.path.insert(0, "../../pahan/sendmsg")
 
5
from sendmsg import sendmsg, SCM_RIGHTS
 
6
from struct import pack
 
7
 
 
8
tf1 = TemporaryFile()
 
9
tf1.write("I hope it breaks and you die")
 
10
tf1.flush()
 
11
tf2 = TemporaryFile()
 
12
tf2.write("I lied!")
 
13
tf2.flush()
 
14
 
 
15
s = socket(AF_UNIX, SOCK_STREAM)
 
16
try:
 
17
    os.unlink("fd_control")
 
18
except OSError:
 
19
    pass
 
20
s.bind("fd_control")
 
21
s.listen(1)
 
22
while 1:
 
23
    b, _ = s.accept()
 
24
    print "Connected", b
 
25
    sendmsg(b.fileno(), "stfu", 0, (SOL_SOCKET, SCM_RIGHTS, pack("2i", tf1.fileno(), tf2.fileno())))
 
26
    print "Sent"
 
27