Results 1 to 8 of 8

Thread: how to stop too many packet in certain time period

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    148

    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.

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    148

    Post Re: how to stop too many packet in certain time period

    Quote 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

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    148

    Re: how to stop too many packet in certain time period

    if the winsock arrival hit 12 times in 1second.

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: how to stop too many packet in certain time period

    So why isn't a Timer working for this? Should work fine.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    148

    Re: how to stop too many packet in certain time period

    oh I was wondering is there a better way to do it lol

  8. #8
    Junior Member
    Join Date
    Sep 2007
    Posts
    29

    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:
    1. 'This will display a messagebox if more than 10 itmes are added in under 5 seconds without using a timer control.
    2.  
    3. Dim lMsgs As Long
    4. Dim lTimer1 As Long, lTimer2 As Long
    5.  
    6.  
    7. Private Sub Command1_Click()
    8.     List1.AddItem lMsgs
    9.     List1.ListIndex = List1.ListCount - 1
    10.     lTimer2 = Timer
    11.     lMsgs = lMsgs + 1
    12.    
    13.     If lMsgs >= 10 Then
    14.         If (lTimer2 - lTimer1) <= 5 Then
    15.             MsgBox lMsgs & " messages have arrived in under 5 seconds."
    16.             lTimer1 = Timer
    17.             lMsgs = 0
    18.         Else
    19.             lTimer1 = Timer
    20.             lMsgs = 0
    21.         End If
    22.     End If
    23.    
    24. End Sub
    25.  
    26. Private Sub Form_Load()
    27.     lTimer1 = Timer
    28. 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
  •  



Click Here to Expand Forum to Full Width