Re: Need a sample of code.
make a string array for those 4 servers and 1 integer variable.. Connect to 1st address in array and set integer value to 1. Then check winsock state, if the connection is not made then close winsock and jump to next server in array (array(yourInteger + 1). and so on.. If yourInteger=4 then Yourinteger=1 again.. To check if server is working you can use Winsock_Connect event, and a timer for timeout.
Re: Need a sample of code.
Re: Need a sample of code.
Something like
VB Code:
Dim sServer As String(4)
Private Sub Form_Activate()
sServer(0) = "z.z.z.z"
sServer(1) = "y.y.y.y"
sServer(2) = "x.x.x.x"
sServer(3) = "w.w.w.w"
End Sub
Private Sub ConnectToServer()
Dim s As String, i As Integer
Do
ConnectToServer(sServer(i))
if ConnectedToServer Then Exit Do
i = i + 1
If i = 4 Then i = 0
While Not ConnectedToServer
'rest of code if connected
End Sub
Private Sub ConnectToServer(sServerName As String)
'code to connect to server
End Sub
Private Function ConnectedToServer() As Boolean
'code to determine whether we're connected to server
'wait while we're connecting - we should get either a connection or a timeout
ConnectedToServer = 'True if we connected, False if we timed out
End Function
Re: Need a sample of code.
Hmm, what about if we dont recieve data it switches to the next server?