author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
Fri, 08 May 2009 16:28:52 +0900 | |
changeset 8384 | 483d9b2103da |
parent 8225 | 46293a0c7e9f |
child 8386 | 4aad982111b6 |
permissions | -rw-r--r-- |
6239 | 1 |
# server.py - inotify common protocol code |
2 |
# |
|
3 |
# Copyright 2006, 2007, 2008 Bryan O'Sullivan <bos@serpentine.com> |
|
4 |
# Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> |
|
5 |
# |
|
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
6239
diff
changeset
|
6 |
# This software may be used and distributed according to the terms of the |
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
6239
diff
changeset
|
7 |
# GNU General Public License version 2, incorporated herein by reference. |
6239 | 8 |
|
9 |
import cStringIO, socket, struct |
|
10 |
||
11 |
version = 1 |
|
12 |
||
13 |
resphdrfmt = '>llllllll' |
|
14 |
resphdrsize = struct.calcsize(resphdrfmt) |
|
15 |
||
16 |
def recvcs(sock): |
|
17 |
cs = cStringIO.StringIO() |
|
18 |
s = True |
|
19 |
try: |
|
20 |
while s: |
|
21 |
s = sock.recv(65536) |
|
22 |
cs.write(s) |
|
23 |
finally: |
|
24 |
sock.shutdown(socket.SHUT_RD) |
|
25 |
cs.seek(0) |
|
26 |
return cs |