I have this code
_socket.BeginReceive(
_buffer,
0,
_buffer.Length,
SocketFlags.None,
_asyncCallback,
sSocketName);
**with**
_buffer.Length = 262144;
_asyncCallback = OnReceive;
sSocketName is a state string object (sSocketName = "History")
And the AsynCallback delegate method:
private void OnReceive(IAsyncResult asyn)
{
if (asyn.AsyncState.ToString().Equals("History"))
{
int receivedBytes = _socket.EndReceive(asyn);
string data = Encoding.ASCII.GetString(_buffer, 0, receivedBytes);
//...
}
//...
}
receivedBytes is an integer which indicate the number of received bytes. In my case, it is around 23,000 -> 25,000.
The socket server is an internet server which keep pushing raw data to my client socket in term of string message, and it has much more more than 25,000 bytes of data.
So my question:
- What determine the number of received bytes?
- And What determine if the receiving is finished?