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

◆ WriteAsync< TAdapter >()

async Task System.Net.Security.NegotiateStream.WriteAsync< TAdapter > ( TAdapter adapter,
ReadOnlyMemory< byte > buffer )
inlineprivate
Type Constraints
TAdapter :IReadWriteAdapter 

Definition at line 611 of file NegotiateStream.cs.

611 : IReadWriteAdapter
612 {
613 if (Interlocked.Exchange(ref _writeInProgress, 1) == 1)
614 {
615 throw new NotSupportedException(System.SR.Format(System.SR.net_io_invalidnestedcall, "Write", "write"));
616 }
617 try
618 {
619 while (!buffer.IsEmpty)
620 {
621 int chunkBytes = Math.Min(buffer.Length, 64512);
622 int count;
623 try
624 {
625 count = EncryptData(buffer.Slice(0, chunkBytes).Span, ref _writeBuffer);
626 }
627 catch (Exception innerException)
628 {
629 throw new IOException(System.SR.net_io_encrypt, innerException);
630 }
631 await adapter.WriteAsync(_writeBuffer, 0, count).ConfigureAwait(continueOnCapturedContext: false);
632 buffer = buffer.Slice(chunkBytes);
633 }
634 }
635 catch (Exception ex) when (!(ex is IOException) && !(ex is OperationCanceledException))
636 {
637 throw new IOException(System.SR.net_io_write, ex);
638 }
639 finally
640 {
642 }
643 }
int EncryptData(ReadOnlySpan< byte > buffer, [NotNull] ref byte[] outBuffer)
static string net_io_invalidnestedcall
Definition SR.cs:24
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_io_encrypt
Definition SR.cs:32
static string net_io_write
Definition SR.cs:38
Definition SR.cs:7
static int Exchange(ref int location1, int value)

References System.Net.Security.NegotiateStream._writeBuffer, System.Net.Security.NegotiateStream._writeInProgress, System.buffer, System.count, System.Net.Security.NegotiateStream.EncryptData(), System.Threading.Interlocked.Exchange(), System.SR.Format(), System.Math.Min(), System.SR.net_io_encrypt, System.SR.net_io_invalidnestedcall, and System.SR.net_io_write.