troubleshooting Question

error in client/server in vb6

Avatar of xodos
xodos asked on
Programming
3 Comments1 Solution333 ViewsLast Modified:
dear sir
i m making an client/server on visual basic 6
the client collects sysinfo and local ip and send it to the server ,
it is working now ,
when a new client appears on the network , it sends the information to the server ,
but when he disconnected , he stills appear on the server list box ,

i want to make it automatically update when the client disconnect ,

client code :
=======
Private Sub Command1_Click()
Call Winsock1.Connect("82.198.5.122", 13164)

Winsock1.SendData GetOSDetails() & " at [" & Winsock1.LocalIP & "]"
End Sub
Private Function GetOSDetails()
   Dim MsgEnd As String
   Select Case SysInfo1.OSPlatform
      Case 0
         MsgEnd = "Unidentified"
      Case 1
         MsgEnd = "Windows 95, ver. " & CStr(SysInfo1.OSVersion) & _
                  "(" & CStr(SysInfo1.OSBuild) & ")"
      Case 2
         MsgEnd = "Windows NT, ver. " & CStr(SysInfo1.OSVersion) & _
                  "(" & CStr(SysInfo1.OSBuild) & ")"
   End Select
   GetOSDetails = "[" & MsgEnd & "]"
End Function


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
      Winsock1.SendData "ShutDown " & Winsock1.LocalIP

End Sub


server code :
========

Private Sub Form_Load()
Winsock1.Bind 13164
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
     Dim s As String
     Dim sender As String
     Call Winsock1.GetData(s, vbString, bytesTotal)
     If UCase(Left(s, 8)) = "SHUTDOWN" Then
          sender = GetSenderIP(s)
          For i = 0 To List1.ListCount
               If GetSenderIP(List1.List(i)) = sender Then
                    ' Write the code to remove the item
               End If
          Next
     Else
          List1.AddItem s
     End If
End Sub
Private Function GetSenderIP(ByVal ClientData As String) As String
     ' Pass the data recd from client to this function and return the IP address of the sender
     ' which is present at the end of the string
End Function
ASKER CERTIFIED SOLUTION
igoruch

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros