]> granicus.if.org Git - python/commitdiff
Reindent code
authorAndrew M. Kuchling <amk@amk.ca>
Wed, 9 Aug 2006 14:06:19 +0000 (14:06 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Wed, 9 Aug 2006 14:06:19 +0000 (14:06 +0000)
Doc/howto/sockets.tex

index 0607a933b4d559a892906ee1ee85b67a3a5b571a..0cecbb9aa6c84571f0417694221f3b59509ebf0c 100644 (file)
@@ -213,37 +213,39 @@ Assuming you don't want to end the connection, the simplest solution
 is a fixed length message:
 
 \begin{verbatim}
-    class mysocket:
-        '''demonstration class only 
-          - coded for clarity, not efficiency'''
-        def __init__(self, sock=None):
-            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
-
-        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
-            return msg
+class mysocket:
+    '''demonstration class only 
+      - coded for clarity, not efficiency
+    '''
+
+    def __init__(self, sock=None):
+       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
+
+    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
+       return msg
 \end{verbatim}
 
 The sending code here is usable for almost any messaging scheme - in