M
Mike Hildner
In all the examples that come with VS, the callback method passed to
BeginReceive look something like:
Dim read As Integer = s.EndReceive(ar)
If read > 0 Then
so.sb.Append(Encoding.ASCII.GetString(so.buffer, 0, read))
s.BeginReceive(so.buffer, 0, StateObject.BUFFER_SIZE, 0, New
AsyncCallback(AddressOf Async_Send_Receive.Read_Callback), so)
Else
' All the data has been read.
So some data comes over, you grab it, then do BeginReceive again in case
there's more data in the buffer (at least in my understanding). But the
documentation says that EndReceive will block until some data is there or
there is a Socket Exception.
Are all these examples incorrect in coding that if the bytes read = 0 then
all the data has been read? The only time my code gets there is when there
is an error.
Just hoping for some clarification,
Mike
BeginReceive look something like:
Dim read As Integer = s.EndReceive(ar)
If read > 0 Then
so.sb.Append(Encoding.ASCII.GetString(so.buffer, 0, read))
s.BeginReceive(so.buffer, 0, StateObject.BUFFER_SIZE, 0, New
AsyncCallback(AddressOf Async_Send_Receive.Read_Callback), so)
Else
' All the data has been read.
So some data comes over, you grab it, then do BeginReceive again in case
there's more data in the buffer (at least in my understanding). But the
documentation says that EndReceive will block until some data is there or
there is a Socket Exception.
Are all these examples incorrect in coding that if the bytes read = 0 then
all the data has been read? The only time my code gets there is when there
is an error.
Just hoping for some clarification,
Mike