本文整理汇总了C#中SNIPacket.TakeData方法的典型用法代码示例。如果您正苦于以下问题:C# SNIPacket.TakeData方法的具体用法?C# SNIPacket.TakeData怎么用?C# SNIPacket.TakeData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SNIPacket
的用法示例。
在下文中一共展示了SNIPacket.TakeData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleReceiveComplete
/// <summary>
/// Process a receive completion
/// </summary>
/// <param name="packet">SNI packet</param>
/// <param name="sniErrorCode">SNI error code</param>
public void HandleReceiveComplete(SNIPacket packet, uint sniErrorCode)
{
SNISMUXHeader currentHeader = null;
SNIPacket currentPacket = null;
SNIMarsHandle currentSession = null;
if (sniErrorCode != TdsEnums.SNI_SUCCESS)
{
lock (this)
{
HandleReceiveError();
return;
}
}
while (true)
{
lock (this)
{
if (_currentHeaderByteCount != SNISMUXHeader.HEADER_LENGTH)
{
currentHeader = null;
currentPacket = null;
currentSession = null;
while (_currentHeaderByteCount != SNISMUXHeader.HEADER_LENGTH)
{
int bytesTaken = packet.TakeData(_headerBytes, _currentHeaderByteCount, SNISMUXHeader.HEADER_LENGTH - _currentHeaderByteCount);
_currentHeaderByteCount += bytesTaken;
if (bytesTaken == 0)
{
sniErrorCode = ReceiveAsync(ref packet);
if (sniErrorCode == TdsEnums.SNI_SUCCESS_IO_PENDING)
{
return;
}
HandleReceiveError();
return;
}
}
_currentHeader = new SNISMUXHeader()
{
SMID = _headerBytes[0],
flags = _headerBytes[1],
sessionId = BitConverter.ToUInt16(_headerBytes, 2),
length = BitConverter.ToUInt32(_headerBytes, 4) - SNISMUXHeader.HEADER_LENGTH,
sequenceNumber = BitConverter.ToUInt32(_headerBytes, 8),
highwater = BitConverter.ToUInt32(_headerBytes, 12)
};
_dataBytesLeft = (int)_currentHeader.length;
_currentPacket = new SNIPacket(null);
_currentPacket.Allocate((int)_currentHeader.length);
}
currentHeader = _currentHeader;
currentPacket = _currentPacket;
if (_currentHeader.flags == (byte)SNISMUXFlags.SMUX_DATA)
{
if (_dataBytesLeft > 0)
{
int length = packet.TakeData(_currentPacket, _dataBytesLeft);
_dataBytesLeft -= length;
if (_dataBytesLeft > 0)
{
sniErrorCode = ReceiveAsync(ref packet);
if (sniErrorCode == TdsEnums.SNI_SUCCESS_IO_PENDING)
{
return;
}
HandleReceiveError();
return;
}
}
}
_currentHeaderByteCount = 0;
if (!_sessions.ContainsKey(_currentHeader.sessionId))
{
SNILoadHandle.SingletonInstance.LastError = new SNIError(SNIProviders.SMUX_PROV, 0, SNICommon.InvalidParameterError, string.Empty);
HandleReceiveError();
_lowerHandle.Dispose();
_lowerHandle = null;
return;
}
//.........这里部分代码省略.........