def fileno(self, fd=_DEFAULT): if fd is _DEFAULT: return pn_selectable_get_fd(self._impl) elif fd is None: pn_selectable_set_fd(self._impl, PN_INVALID_SOCKET) else: pn_selectable_set_fd(self._impl, fd)
def get_acceptor_sockname(self): # type: () -> (str, int) self._acceptor_opened_event.wait() if hasattr(self.acceptor, '_selectable'): # proton 0.30.0+ sockname = self.acceptor._selectable._delegate.getsockname() else: # works in proton 0.27.0 selectable = cproton.pn_cast_pn_selectable(self.acceptor._impl) fd = cproton.pn_selectable_get_fd(selectable) s = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) sockname = s.getsockname() return sockname[:2]