Results 1 to 4 of 4

Thread: VB6 making function wait for winsock data arrival

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    1

    Post VB6 making function wait for winsock data arrival

    I am making a program in which I want to make a function send data on network using winsock. I want to make my function to wait until data is received at TCP port. And when data is received it should again start its execution.
    Thanks

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: VB6 making function wait for winsock data arrival

    Moved from Visual Basic FAQs

  3. #3
    Addicted Member
    Join Date
    Jan 2007
    Location
    Iran
    Posts
    237

    Re: VB6 making function wait for winsock data arrival

    I using Pause:

    Public Sub Pause(Second As Double)
    On Error Resume Next

    Dim Dim_Dbl_AtTime As Double

    Dim_Dbl_AtTime = Timer

    Do While Timer - Dim_Dbl_AtTime < Val(Second)
    DoEvents
    Loop

    End Sub
    Y.P.Y

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

    Re: VB6 making function wait for winsock data arrival

    You can't.

    TCP is a reliable stream protocol. This means the underlying software tries very hard to make sure everything arrives and is presented in the proper sequence. This involves a lot of buffering and control operations you have no direct access to from where your program is.

    The question is a little like asking how to know a record got written to disk. Using high-level stream I/O you don't get such notifications.

    Unless the receiving program watches everything it receives and sends back some kind of notification your TCP program will never really know when complete data was received. Why should it? TCP wasn't designed to be used that way. It isn't message oriented, it is based on continuous streams and works very hard to abstract away the underlying exchange of packets, the windowing it does, the retry requests it makes, congestion control, stream reassembly, and lots of other things.


    Maybe if you back up and describe what you want to accomplish at a higher level you'll get more useful responses.

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