delphi - Tclientsocket if socket can't connect -


i want sockets connects backuphost when socket can't connect host, tried this:

if prclient.socket.connected = false begin prclient.active := false; prclient.port := port; prclient.host := host; prclient.active := true; prclient.open; sleep(500); if prclient.socket.connected = false begin prclient.active := false; prclient.host := backuphost; prclient.active := true; prclient.open; end; end; 

but doesn't connect @ all. knows working script?

if using socket in blocking mode both active:=true , open() (which should not using together!) raise exception if connection fails:

prclient.port := port; prclient.host := host; try   prclient.open; except   prclient.host := backuphost;   prclient.open; end; 

if using socket in non-blocking mode, no exception raised (unless socket api function fails), conection attempted in background, , notified of final result via onconnect or onerror event depending on whether connection succeeds or fails, respectively.


Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -