HI! All
I want to make a function on my server side,
if in 10second get 12 packet then stop that getting data else reset the time
thank you much.
Printable View
HI! All
I want to make a function on my server side,
if in 10second get 12 packet then stop that getting data else reset the time
thank you much.
Is this visual basic? 6? .NET? What are you using in the server? Winsock?
Please be more specific.
Quote:
Originally Posted by DigiRev
hi DigiRev
Yeah i'm using vb6 with winsock
right now i using a timer to see the time but i want to see if there a better way to do this.
thankx
What do you mean by "packet?" People use this term a lot but it is meaningless with a TCP connection, which is a byte stream.
Just because a sender calls SendData 12 times does not mean the receiver will see 12 Data Arrival events. The receiver may see just 1, or 12, or 5, or 35. Buffering and segmentation can occur in many places between sender and receiver.
if the winsock arrival hit 12 times in 1second.
So why isn't a Timer working for this? Should work fine.
oh I was wondering is there a better way to do it :D lol
You could try setting a variable to hold the current timer value (lTimer1 = Timer) and then each time a data packet comes in have it check it against the current timer value, also storing the amout of packets have been recieved since the last check. Here's a quick example of what i mean:
Make a new standard exe, add a listbox and a command button. then put this code in.
vb Code:
'This will display a messagebox if more than 10 itmes are added in under 5 seconds without using a timer control. Dim lMsgs As Long Dim lTimer1 As Long, lTimer2 As Long Private Sub Command1_Click() List1.AddItem lMsgs List1.ListIndex = List1.ListCount - 1 lTimer2 = Timer lMsgs = lMsgs + 1 If lMsgs >= 10 Then If (lTimer2 - lTimer1) <= 5 Then MsgBox lMsgs & " messages have arrived in under 5 seconds." lTimer1 = Timer lMsgs = 0 Else lTimer1 = Timer lMsgs = 0 End If End If End Sub Private Sub Form_Load() lTimer1 = Timer End Sub
I changed it to 10 messages in under 5 seconds so its is easier for testing. Hope that helps.