(self, sz)
| 63 | self.handle.connect((self.host, self.port)) |
| 64 | |
| 65 | def read(self, sz): |
| 66 | try: |
| 67 | buff = self.handle.recv(sz) |
| 68 | except socket.error, e: |
| 69 | if (e.args[0] == errno.ECONNRESET and |
| 70 | (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))): |
| 71 | # freebsd and Mach don't follow POSIX semantic of recv |
| 72 | # and fail with ECONNRESET if peer performed shutdown. |
| 73 | # See corresponding comment and code in TSocket::read() |
| 74 | # in lib/cpp/src/transport/TSocket.cpp. |
| 75 | self.close() |
| 76 | # Trigger the check to raise the END_OF_FILE exception below. |
| 77 | buff = '' |
| 78 | else: |
| 79 | raise |
| 80 | except Exception, e: |
| 81 | # SSL connection was closed |
| 82 | if e.args == (-1, 'Unexpected EOF'): |
| 83 | buff = '' |
| 84 | elif e.args == ([('SSL routines', 'SSL23_GET_CLIENT_HELLO', 'unknown protocol')],): |
| 85 | #a socket not using ssl tried to connect |
| 86 | buff = '' |
| 87 | else: |
| 88 | raise |
| 89 | |
| 90 | if not len(buff): |
| 91 | raise TTransportException(type=TTransportException.END_OF_FILE, message='TSocket read 0 bytes') |
| 92 | return buff |
| 93 | |
| 94 | |
| 95 | class ServerSocket(TServerSocket, Socket): |
no test coverage detected