| 52 | pass |
| 53 | |
| 54 | class Connection: |
| 55 | def __init__(self, connection): |
| 56 | self.connection = connection |
| 57 | self.file = connection.makefile("rb") |
| 58 | |
| 59 | def send(self, command): |
| 60 | line = command + "\n" |
| 61 | data = line.encode() |
| 62 | self.connection.send(data) |
| 63 | |
| 64 | def receive(self): |
| 65 | line = self.file.readline() |
| 66 | if not line: |
| 67 | raise EOFError("Connection closed") |
| 68 | return line[:-1].decode() |
| 69 | |
| 70 | |
| 71 | print("Example 2") |