Attribute VB_Name = "modNetworkConnection" Option Explicit Public Function FastConnection(ServerIP As String) As Boolean On Error GoTo ErrTrap 'Exit Function Dim conMessage As String ' txtConnecting.text = "Looking up server." conMessage = "Looking up server." Dim Winsock1 As Object Set Winsock1 = CreateObject("MSWinsock.Winsock") Dim CheckTime As Date Dim HostIP As String Dim HostPort As String HostIP = GetWord(ServerIP, ",") HostPort = ServerIP If HostPort = "" Then HostPort = 10000 End If FastConnection = False With Winsock1 .Close .RemoteHost = HostIP .RemotePort = HostPort .Connect CheckTime = Now ' Do While DateDiff("s", CheckTime, Now) < 3 And txtConnecting.text <> "Connected." Do While DateDiff("s", CheckTime, Now) < 3 And conMessage <> "Connected." 'MsgBox .State ' WinSock.State = sckClosed = 0 ' WinSock.State = sckOpen = 1 ' WinSock.State = sckListening = 2 ' WinSock.State = sckConnectionPending = 3 ' WinSock.State = sckResolvingHost = 4 ' WinSock.State = sckHostResolved = 5 ' WinSock.State = sckConnecting = 6 ' WinSock.State = sckConnected = 7 ' WinSock.State = sckClosing = 8 ' WinSock.State = sckError = 9 If .State = 7 Then FastConnection = True ' txtConnecting.text = "Server found." conMessage = "Server found." Exit Do End If ' txtConnecting.text = "Looking up server. " & 3 - DateDiff("s", CheckTime, Now) & " state: " & .State conMessage = "Looking up server. " & 3 - DateDiff("s", CheckTime, Now) & " state: " & .State DoEvents Loop .Close ' If FastConnection = False Then ' txtConnecting.Text = "Count not look up up server." ' End If ' If txtConnecting.text = "Connected." Then If conMessage = "Connected." Then FastConnection = True End If If FastConnection = True Then doAction = "init" ' StartConnectServer Else 'txtConnecting.Text = "Server not found." ' txtConnecting.text = "..." conMessage = "..." End If End With Exit Function ErrTrap: ' txtConnecting.text = "..." & Err.Description & " Error on CheckConnection by Winsock." conMessage = "..." & Err.Description & " Error on CheckConnection by Winsock." End Function Private Sub mHelp_Click() Dim r As Long r = ShellExecute(0, "open", "https://sites.google.com/gomedsys.com/his/messaging", 0, 0, 1) End Sub