If you are using the socket in blocking mode then both Active:=True
and Open()
(which you SHOULD NOT be using together!) will raise an exception if the connection fails:
prclient.Port := PORT;
prclient.Host := HOST;
try
prclient.Open;
except
prclient.Host := BACKUPHOST;
prclient.Open;
end;
If you are using the socket in non-blocking mode, then no exception is raised (unless a socket API function fails), the conection is attempted in the background, and you will be notified of the final result via the OnConnect
or OnError
event depending on whether the connection succeeds or fails, respectively.