SetBuffer를 SocketAsyncEventArgs와 함께 사용할 수 있습니다.어떻게 BufferList를 SocketAsyncEventArgs와 함께 사용하고 SocketError InvalidArgument를 가져 오지 않습니까?
SetBuffer (null, 0, 0)을 수행 한 후 BufferList를 사용하려고하면 소켓에서 SendAsync를 수행 할 때 항상 SocketError InvalidArgument (10022)가 발생합니다.
BufferList를 사용하는 방법에 대한 예제 나 문서가 없으며 내가하고있는 일이 (어쨌든 나에게) 의미가 있습니다.
예제 프로그램이나 코드 조각을 지적 할 수 있습니까?
나는이 이상 내 머리를 찢어있어 훨씬 여기
내가 전자가 SocketAsyncEventArgs입니다 (뭘 오전 기본적으로 ... 왼쪽하지 않고 lSocket 작동 내가 SetBuffer 사용하는 것과 동일한 소켓입니다)// null the buffer since we will use a buffer list
e.SetBuffer(null, 0, 0);
// create a bufferlist
e.BufferList = new List<ArraySegment<byte>>();
// create the bufferlist with the network header and the response bytes
e.BufferList.Add(new ArraySegment<byte>(lTxBytes)); // add the 4 character total length
e.BufferList.Add(new ArraySegment<byte>(Encoding.ASCII.GetBytes(lTx.Identity))); // echo back the incoming sequence number
e.BufferList.Add(new ArraySegment<byte>(Encoding.ASCII.GetBytes(lResponse)));
// *** the SendAsync always completes IMMEDIATELY (returns false) gets SocketError InvalidArgument (10022)
if (lSocket.SendAsync(e) == false)
{
// data was already sent back to the client.
AppSupport.WriteLog(LogLevel.Flow, "ProcessReceive had SendAsync complete synchronously (bytes transferred {0}).", e.BytesTransferred);
ProcessSend(e);
}
사용하는 언어로 태그를 지정하면 질문에 대한 답변을 얻을 확률이 높아집니다. –
모든 ArraySegments가 동일한 물리적 바이트 배열에 속해야합니까? 그렇다면 BufferList를 쓸모 없게 만듭니다. 누구든지 BufferList를 성공적으로 사용 했습니까? – Dave
누구나 여기에 아이디어가 있습니까? – Dave