|
-
Aug 31st, 2007, 09:55 PM
#1
Thread Starter
Addicted Member
how to stop too many packet in certain time period
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.
-
Sep 1st, 2007, 12:06 AM
#2
Re: how to stop too many packet in certain time period
Is this visual basic? 6? .NET? What are you using in the server? Winsock?
Please be more specific.
-
Sep 1st, 2007, 03:31 AM
#3
Thread Starter
Addicted Member
Re: how to stop too many packet in certain time period
 Originally Posted by DigiRev
Is this visual basic? 6? .NET? What are you using in the server? Winsock?
Please be more specific.
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
-
Sep 2nd, 2007, 10:32 AM
#4
Re: how to stop too many packet in certain time period
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.
-
Sep 2nd, 2007, 12:24 PM
#5
Thread Starter
Addicted Member
Re: how to stop too many packet in certain time period
if the winsock arrival hit 12 times in 1second.
-
Sep 2nd, 2007, 07:29 PM
#6
Re: how to stop too many packet in certain time period
So why isn't a Timer working for this? Should work fine.
-
Sep 2nd, 2007, 10:51 PM
#7
Thread Starter
Addicted Member
Re: how to stop too many packet in certain time period
oh I was wondering is there a better way to do it lol
-
Sep 23rd, 2007, 07:50 PM
#8
Junior Member
Re: how to stop too many packet in certain time period
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.
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
|