Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FillHandshakeBufferAsync< TIOAdapter >()

ValueTask< int > System.Net.Security.SslStream.FillHandshakeBufferAsync< TIOAdapter > ( TIOAdapter adapter,
int minSize )
inlineprivate
Type Constraints
TIOAdapter :IReadWriteAdapter 

Definition at line 1653 of file SslStream.cs.

1653 : IReadWriteAdapter
1654 {
1655 if (_handshakeBuffer.ActiveLength >= minSize)
1656 {
1657 return new ValueTask<int>(minSize);
1658 }
1659 int byteCount = minSize - _handshakeBuffer.ActiveLength;
1661 while (_handshakeBuffer.ActiveLength < minSize)
1662 {
1663 ValueTask<int> task2 = adapter.ReadAsync(_handshakeBuffer.AvailableMemory);
1664 if (!task2.IsCompletedSuccessfully)
1665 {
1666 return InternalFillHandshakeBufferAsync(adapter, task2, minSize);
1667 }
1668 int result = task2.Result;
1669 if (result == 0)
1670 {
1671 return new ValueTask<int>(0);
1672 }
1673 _handshakeBuffer.Commit(result);
1674 }
1675 return new ValueTask<int>(minSize);
1676 async ValueTask<int> InternalFillHandshakeBufferAsync(TIOAdapter adap, ValueTask<int> task, int minSize)
1677 {
1678 while (true)
1679 {
1680 int num = await task.ConfigureAwait(continueOnCapturedContext: false);
1681 if (num == 0)
1682 {
1683 throw new IOException(System.SR.net_io_eof);
1684 }
1686 if (_handshakeBuffer.ActiveLength >= minSize)
1687 {
1688 break;
1689 }
1690 task = adap.ReadAsync(_handshakeBuffer.AvailableMemory);
1691 }
1692 return minSize;
1693 }
1694 }
static string net_io_eof
Definition SR.cs:40
Definition SR.cs:7
Memory< byte > AvailableMemory
void Commit(int byteCount)
void EnsureAvailableSpace(int byteCount)
ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)
Definition ValueTask.cs:312

References System.Net.Security.SslStream._handshakeBuffer, System.Net.ArrayBuffer.ActiveLength, System.Net.ArrayBuffer.AvailableMemory, System.byteCount, System.Net.ArrayBuffer.Commit(), System.Threading.Tasks.ValueTask< TResult >.ConfigureAwait(), System.Net.ArrayBuffer.EnsureAvailableSpace(), System.Threading.Tasks.ValueTask< TResult >.IsCompletedSuccessfully, System.SR.net_io_eof, System.Threading.Tasks.ValueTask< TResult >.Result, and System.task.