first of all,plz forgive my pool engilsh.
I’m currently studying the tcp receive programming.And while I’m using ReceiveAsync(Memory, SocketFlags, CancellationToken) method, I just receive nothing in the memory.
public async Task BeginTcpRecieve()
{
try
{
//ArraySegment<byte> bytes = new ArraySegment<byte>(tcpRecReserve,catchNum, tcpRecReserve.Length - catchNum);
Memory<byte> memory = new Memory<byte>(tcpRecReserve, catchNum, tcpRecReserve.Length - catchNum);
int reclen = await tcpSocket.ReceiveAsync(memory, SocketFlags.None);
HandleReceive(reclen);
await BeginTcpRecieve();
}
catch (SocketException e)
{
print(e.ErrorCode + "/" + e.Message);
isConnected= false;
}
}
However, it works well when i switch to ReceiveAsync(ArraySegment, SocketFlags) method.My question is why this happened and how can i solute it.
New contributor
Nocpe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.