Jump to content
fatimire

TWSocket Port or Host error

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×