What is the Code to display connected computers?
Hi i just join this forum. I'm doing on a project to control the computers in my campus lab. It need to display computers which just on and to display the number of connected computer. The code i have can only display the computers which are connected to the same network as mine if they off their computer then it won't display anymore. I also need to display the computer which are off coz i have to do Wake on LAN on them to wake them up. Please help me....
Re: What is the Code to display connected computers?
Is this a winsock app and the other computer is connected via sockets? Or is it just a windows Local Area Network and you want to find out about the connected PCs on the LAN?
If its a winsock app can you please post the entire code for the winsock events
Re: What is the Code to display connected computers?
Provided you havein your Winsock_Close and Winsock_Error events you should be able to use a timer like the other thread
VB Code:
Dim i as Integer
Dim OnlineUsers as Integer
For i = 1 to Winsock1.UBound
If Winsock1(i).State = sckConnected Then
OnlineUsers = OnlineUsers + 1
End If
Next i
Label1.Caption = "There are currently: " & OnlineUsers & " computers connected."
You could also do it by just updating the onlineusers when a socket is closed and when a new socket is connected:)
My server coding to connect to client
Private Sub lstComputers_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
Dim i As Integer
Dim PCName As String
Dim RemoteHost As String
If lstComputers.Selected(selectedPC_index) = True Then
If Button = 2 Then ' if the mousebutton 2 is pressed (right)
PopupMenu Rclick ' then it calls the menu which is hidden to be shown
' at the cordinates of the mousepointer (x,y)
Else
Button = 1
RemoteHost = lstComputers.List(selectedPC_index)
sckControlPanel.RemoteHost = RemoteHost
sckControlPanel.RemotePort = 8005
sckControlPanel.Connect
End If
Else
sckControlPanel.Close
Call sckControlPanel_Close
End If
Data1.Refresh
End Sub
Re: What is the Code to display connected computers?
This wont solve your problem, but you need to change your if statements to this:
VB Code:
Private Sub lstComputers_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
Dim i As Integer
Dim PCName As String
Dim RemoteHost As String
If lstComputers.Selected(selectedPC_index) = True Then
If Button = 2 Then ' if the mousebutton 2 is pressed (right)
PopupMenu Rclick ' then it calls the menu which is hidden to be shown
' at the cordinates of the mousepointer (x,y)
Elseif Button = 1 then
RemoteHost = lstComputers.List(selectedPC_index)
sckControlPanel.RemoteHost = RemoteHost
sckControlPanel.RemotePort = 8005
sckControlPanel.Connect
End If
Else
sckControlPanel.Close
Call sckControlPanel_Close
End If
Data1.Refresh
End Sub
Re: What is the Code to display connected computers?
If you read my post carefully it tells you to put that in a timer, not the close event, it tells you you need Sock.Close in the close event..........
I thought you said this was an app which many more than 1 client connect in which case you need a socket array sckControlPanel() but from your code you seem to just have a single socket with no array, one socket can only handle one connection.
Its giving error because you dont have an array you only have the single socket
Can you show me how to do that?
Can you show me how to do a socket array sckControlPanel()? I'm still not that good with this. Yes sorry i miss out the word timer. Can you give me more guide on this matter.. Thanks alot in advance.