SetBuffer'ı SocketAsyncEventArgs ile birlikte kullanabilirim.SocketAsyncEventArgs ile BufferList nasıl kullanılır ve SocketError InvalidArgument'i alamıyorsunuz?
BufferList'i kullanmaya çalışırsam (SetBuffer'ı (null, 0, 0) yaptıktan sonra) her zaman ve hemen Soket üzerine SendAsync yaptığımda hemen SocketError InvalidArgument (10022) alırım.
BufferList'in nasıl kullanıldığına ve ne yaptığımın mantıklı olduğuna dair bir örnek veya belge yok (yine de bana).
Birisi örnek bir program veya kod pasajına işaret edebilir mi?
Ben bu aşkın olsam deliye ediyorum ve çok Burada
Ben e SocketAsyncEventArgs olduğunu (ne yapıyorum temelde ... bırakmış yoktur ve lSocket işleri ben setbuffer için kullanmak sokettir)// 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);
}
Kullandığınız dil ile etiketliyorsanız, sorunuza yanıt almak için daha iyi bir şansa sahipsiniz. –
Tüm ArraySegments'ın aynı fiziksel bayt dizisinin bir parçası olması gerekiyor mu? Eğer durum buysa, BufferList'i işe yaramaz hale getirecektir. BufferList'i başarıyla kullanan var mı? – Dave
Burada herhangi bir fikri olan var mı? – Dave