According to source code here, behind the scene the adb connect invokes adb_query that returns a char array. This char array contains the result of the socket request call, something that can be displayed as string in the terminal (your 'connection refused' message for instance).
adb_query handles error scenarios as well but the issues that can be captured are more related to file descriptor (for socket communication) or memory allocation. When such cases happen then echo $? will return 1.
That said, the answer to your question is, yes, this is the intended behaviour.
According to source code here, behind the scene the
adb connectinvokesadb_querythat returns a char array. This char array contains the result of the socket request call, something that can be displayed as string in the terminal (your 'connection refused' message for instance).adb_queryhandles error scenarios as well but the issues that can be captured are more related to file descriptor (for socket communication) or memory allocation. When such cases happen thenecho $?will return1.That said, the answer to your question is, yes, this is the intended behaviour.