def METHOD_NAME(self, sock):
    try:
        data = sock.recv(1)
        if len(data) == 1 and self.expect_disconnect:
            raise ValueError("Still connected")
    except ConnectionResetError:
        if self.expect_disconnect:
            pass
        else:
            raise