Robert A. van Ginkel said:
In I ask the question how I
can see if all the data is on the other side of the connection.
I got as answer that I should use the blocking property.
I tried this I don't see any diffents, I am sending 10Mb and the
Send/BeginSend command doesn't wait till the data is on the remotepoint.
Can somebody pls. explain this.
Robert -
Whether you are using synchronous or asynchronous sockets, there
is no possible way for one end of the connection to know that it has
received all of the data unless it is told by the other end of the
connection. With TCP, there is no guarantee that all of the data will
arrive in a steady stream. There are often delays between packets as
they are sent on the network. This causes the Receive() method to
assume the data stream is complete and finish the call. It is the
receiving program's job to determine if there is really more data to
be read. There are two common techniques to do this:
If only one data stream is sent between the two sides, then the
sending side can close the socket when it is finished sending bytes.
The receiving side can then read data until the Recieve() method
returns 0 bytes, indicating that the connection was closed, and all of
the data was received.
If you must leave the connection active after the data stream, the
best way to determine if all of the data is received is by having the
sending side first send the size of the data to the receiving side,
then send the actual data. The receiving side can then loop on the
Receive() methods (either sync or async) until it knows all of the
data has been received (by keeping track of the number of bytes
received).
Hope this helps shed some light on your problem.
Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471433012.html