If I use xtigervncviewer to try to connect to a host which doesn't run a VNC server, it prints the following expected error to stderr:
$ xtigervncviewer -AlertOnFatalError=0 localhost
TigerVNC Viewer 64-bit v1.9.0
Built on: 2020-01-23 18:03
Copyright (C) 1999-2018 TigerVNC Team and many others (see README.rst)
See http://www.tigervnc.org for information on TigerVNC.
Fri May 1 15:55:44 2020
DecodeManager: Detected 4 CPU core(s)
DecodeManager: Creating 4 decoder thread(s)
CConn: unable to create socket: Address family not supported by protocol
(97)
Alike, if I try to connect to a non-existing host:
$ xtigervncviewer -AlertOnFatalError=0 nonexistinghost
TigerVNC Viewer 64-bit v1.9.0
Built on: 2020-01-23 18:03
Copyright (C) 1999-2018 TigerVNC Team and many others (see README.rst)
See http://www.tigervnc.org for information on TigerVNC.
Fri May 1 16:36:13 2020
DecodeManager: Detected 4 CPU core(s)
DecodeManager: Creating 4 decoder thread(s)
CConn: unable to resolve host by name: Name or service not known
However, in both cases, the return code is zero:
$ echo $?
0
How can I find out if the connection succeeded or if there was a connection error?