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
See here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mswnsk98/dt_vbobjWinsockControl_E.asp
for more information.
-