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
Printable View
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
Moved from Visual Basic FAQs
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
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.