Results 1 to 2 of 2

Thread: Winsock Help........ may be its tricky...

  1. #1

    Thread Starter
    Addicted Member _RaJ_'s Avatar
    Join Date
    Apr 2008
    Location
    India!
    Posts
    198

    Winsock Help........ may be its tricky...

    i am receiving data from winsock.getdata sdata

    the arrival data is big & comes in part by part that causes dataarrival event to fire more than 1 time........ how can i get whole data once & fire the arrival event once..

    even with winsock.peekdata the event is fired more than 1 time..

    ??

    thnx in adv

    ●════════════════════════════◄►═════════════════════════●
    ___itš bεttεг tΘ bε απ Θρεπ šiππεг, thαπ α ƒαlšε šαiπt___
    ●════════════════════════════◄►═════════════════════════●
    гαj

  2. #2
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Winsock Help........ may be its tricky...

    That's how Winsock works. You can't receive large amounts of data at once. The DataArrival event fires multiple times with small chunks of data of a few kilobytes in size. You will have to buffer the incoming data and check if everything has been received.

    This is a very basic example.

    vb Code:
    1. Private sBuffer As String
    2.  
    3. Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
    4.     Dim sData As String
    5.  
    6.     Winsock.GetData sData, vbString 'get data
    7.  
    8.     sBuffer = sBuffer & sData 'buffer data
    9.  
    10.     If InStr(1, sBuffer, "<end of data>") Then 'look for the end of the data
    11.    
    12.         'all data has been received
    13.    
    14.     End If
    15. End Sub

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