|
-
Dec 11th, 2001, 11:35 AM
#1
Thread Starter
Addicted Member
Winsock
Hi I was wondering if anyone had a very very very simple winsock control that just sent 1 packet to a server evey 5mins and when it stops the server takes off that pc
What its for is a computer room so i can see what pc's are turned on and what arnt in use using a client server setup. Having never used winsock before I'm completely stuck looking at some of the tutorials 
Andy
-
Dec 11th, 2001, 01:47 PM
#2
Thread Starter
Addicted Member
no one
-
Dec 11th, 2001, 01:49 PM
#3
just make a timer control and set the interval to 5000 and put this in it
Wsk.SendData mydata
doEvents
and the server has to log the time that the last package has received.
-
Dec 11th, 2001, 01:58 PM
#4
My English are not very well but i development very system based in winsocket (UDP/TCP), tell me better and send the code for a better anwser !
-
Dec 11th, 2001, 05:09 PM
#5
Thread Starter
Addicted Member
Thats the problem.
I have no source atm and
Code:
just make a timer control and set the interval to 5000 and put this in it
Wsk.SendData mydata
doEvents
and the server has to log the time that the last package has received.
is very helpfull but I'm still unsure on how to get the server to log its data and how to specify IP etc.
-
Dec 11th, 2001, 06:32 PM
#6
hehe, I think there is a better way! 
Make a winsock control array. You can identify each client with the index of the winsock control that the client is connected to. you can make a simple array that has the same number of elements that the winsock control has ( dim myArray (50) as string )
put some code to store a ID for each computer when they connect
VB Code:
Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)
' Do other stuff .....
myArray(index) = "Client #" & index
End Sub
Private Sub Winsock1_Close(Index As Integer)
MsgBox myArray (index) & " has logged off."
End sub
I'm not a very good programmer, so I'm sure there are better ways to do this!!! that might help you too
-
Dec 12th, 2001, 03:35 AM
#7
Thread Starter
Addicted Member
Right so far I've done this
Server =
Code:
Dim connection As Boolean
Private Sub Form_Load()
Winsock1.Close
Winsock1.LocalPort = 1008
Winsock1.Listen
End Sub
Private Sub Timer1_Timer()
If connection = False Then text1.Text = ""
connection = False
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strIncoming As String
Winsock1.GetData strIncoming
If text1.Text = "" Then
text1.Text = strIncoming
End If
connection = True
End Sub
Private Sub Winsock1_close()
Form_Load
End Sub
client =
Code:
Private Sub Form_Load()
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.RemotePort = 1008
Winsock1.RemoteHost = ipadd.Text
Winsock1.Connect
Do Until Winsock1.State = sckConnected
DoEvents: DoEvents: DoEvents: DoEvents
If Winsock1.State = sckError Then
MsgBox "Problem connecting!"
Exit Sub
End If
Loop
End Sub
Private Sub Timer1_Timer()
Winsock1.SendData ("datatest1")
End Sub
I need to know how you can get more than 1 client ocnnecting at a time andhow to get the different clients to show in different text boxes.
Andy
-
Dec 12th, 2001, 03:56 AM
#8
Hyperactive Member
Originally posted by MrPolite
just make a timer control and set the interval to 5000 and put this in it
Wsk.SendData mydata
doEvents
It needs to be corrected...
timer has mazimum interval of 65535 milisecods which is just over a minute. so you must keep conting each minute or you must use
GetTickCount API function for this purpose
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|