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

◆ SendFileAsync() [2/2]

ValueTask System.Net.Sockets.Socket.SendFileAsync ( string? fileName,
ReadOnlyMemory< byte > preBuffer,
ReadOnlyMemory< byte > postBuffer,
TransmitFileOptions flags,
CancellationToken cancellationToken = default(CancellationToken) )
inline

Definition at line 4204 of file Socket.cs.

4205 {
4206 if (cancellationToken.IsCancellationRequested)
4207 {
4209 }
4211 {
4212 SocketException exception = new SocketException(10057);
4213 return ValueTask.FromException((Exception)(object)exception);
4214 }
4215 int num = 0;
4216 if (fileName != null)
4217 {
4218 num++;
4219 }
4220 if (!preBuffer.IsEmpty)
4221 {
4222 num++;
4223 }
4224 if (!postBuffer.IsEmpty)
4225 {
4226 num++;
4227 }
4228 AwaitableSocketAsyncEventArgs awaitableSocketAsyncEventArgs = Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ?? new AwaitableSocketAsyncEventArgs(this, isReceiveForCaching: false);
4229 SendPacketsElement[]? sendPacketsElements = awaitableSocketAsyncEventArgs.SendPacketsElements;
4230 SendPacketsElement[] array = ((sendPacketsElements != null && sendPacketsElements.Length == num) ? awaitableSocketAsyncEventArgs.SendPacketsElements : new SendPacketsElement[num]);
4231 int num2 = 0;
4232 if (!preBuffer.IsEmpty)
4233 {
4234 array[num2++] = new SendPacketsElement(preBuffer, num2 == num);
4235 }
4236 if (fileName != null)
4237 {
4238 array[num2++] = new SendPacketsElement(fileName, 0, 0, num2 == num);
4239 }
4240 if (!postBuffer.IsEmpty)
4241 {
4242 array[num2++] = new SendPacketsElement(postBuffer, num2 == num);
4243 }
4244 awaitableSocketAsyncEventArgs.SendPacketsFlags = flags;
4245 awaitableSocketAsyncEventArgs.SendPacketsElements = array;
4246 awaitableSocketAsyncEventArgs.WrapExceptionsForNetworkStream = false;
4247 return awaitableSocketAsyncEventArgs.SendPacketsAsync(this, cancellationToken);
4248 }
AwaitableSocketAsyncEventArgs _singleBufferSendEventArgs
Definition Socket.cs:569
static int Exchange(ref int location1, int value)
static ValueTask FromCanceled(CancellationToken cancellationToken)
Definition ValueTask.cs:180
static ValueTask FromException(Exception exception)
Definition ValueTask.cs:190

References System.Net.Sockets.Socket._singleBufferSendEventArgs, System.array, System.cancellationToken, System.exception, System.Threading.Interlocked.Exchange(), System.Threading.Tasks.ValueTask< TResult >.FromCanceled(), System.Threading.Tasks.ValueTask< TResult >.FromException(), and System.Net.Sockets.Socket.IsConnectionOriented.