summaryrefslogtreecommitdiffstats
path: root/Doc/howto/sockets.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-03 21:26:05 (GMT)
committerGeorg Brandl <georg@python.org>2009-01-03 21:26:05 (GMT)
commita1c6a1cea5af1d3c7682a8e99b001b0904480e4d (patch)
tree85461d1ba5237440b36f253b197779190226a294 /Doc/howto/sockets.rst
parent48310cd3f2e02ced9ae836ccbcb67e9af3097d62 (diff)
downloadcpython-a1c6a1cea5af1d3c7682a8e99b001b0904480e4d.zip
cpython-a1c6a1cea5af1d3c7682a8e99b001b0904480e4d.tar.gz
cpython-a1c6a1cea5af1d3c7682a8e99b001b0904480e4d.tar.bz2
Merged revisions 68221 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68221 | georg.brandl | 2009-01-03 22:04:55 +0100 (Sat, 03 Jan 2009) | 2 lines Remove tabs from the documentation. ........
Diffstat (limited to 'Doc/howto/sockets.rst')
-rw-r--r--Doc/howto/sockets.rst30
1 files changed, 15 insertions, 15 deletions
diff --git a/Doc/howto/sockets.rst b/Doc/howto/sockets.rst
index 69130c4..9f7fe68 100644
--- a/Doc/howto/sockets.rst
+++ b/Doc/howto/sockets.rst
@@ -189,30 +189,30 @@ length message::
"""
def __init__(self, sock=None):
- if sock is None:
- self.sock = socket.socket(
- socket.AF_INET, socket.SOCK_STREAM)
- else:
- self.sock = sock
+ if sock is None:
+ self.sock = socket.socket(
+ socket.AF_INET, socket.SOCK_STREAM)
+ else:
+ self.sock = sock
def connect(self, host, port):
self.sock.connect((host, port))
def mysend(self, msg):
- totalsent = 0
- while totalsent < MSGLEN:
- sent = self.sock.send(msg[totalsent:])
- if sent == 0:
- raise RuntimeError("socket connection broken")
- totalsent = totalsent + sent
+ totalsent = 0
+ while totalsent < MSGLEN:
+ sent = self.sock.send(msg[totalsent:])
+ if sent == 0:
+ raise RuntimeError("socket connection broken")
+ totalsent = totalsent + sent
def myreceive(self):
msg = ''
while len(msg) < MSGLEN:
- chunk = self.sock.recv(MSGLEN-len(msg))
- if chunk == '':
- raise RuntimeError("socket connection broken")
- msg = msg + chunk
+ chunk = self.sock.recv(MSGLEN-len(msg))
+ if chunk == '':
+ raise RuntimeError("socket connection broken")
+ msg = msg + chunk
return msg
The sending code here is usable for almost any messaging scheme - in Python you