fatimire 0 Posted October 29, 2019 Hello everbody, i need to change the port or host when i cant connect, let me explain better. example: try to connect to host1 on port1 if error connect to host1 on port2 if error connect to host2 on port1 if error connect to host2 on port2 What is the better way to do it ? Using the onError event? Using the WSocket1SessionClosed event? Exists another way without use events? Thanks a lot! Share this post Link to post
Angus Robertson 574 Posted October 29, 2019 This depends on whether you are connecting synchronously or asynchronously. For sync, a simple loop is all that is needed, but your loop will be blocked for up to a minute during each connection attempt depending on TCP/IP timeouts, look at function FtpLogon in OverbyteIcsFtpMulti which does this for different IP addresses. For async, you use the onSessionConnected event which is called whether a connection is OK or fails. Look at SocketSessionConnected in OverbyteIcsIpStreamLog which handles retries after a delay. Angus Share this post Link to post