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

◆ ConnectAsync() [2/11]

ValueTask System.Net.Sockets.Socket.ConnectAsync ( EndPoint remoteEP,
CancellationToken cancellationToken )
inline

Definition at line 3909 of file Socket.cs.

3910 {
3911 if (cancellationToken.IsCancellationRequested)
3912 {
3914 }
3915 AwaitableSocketAsyncEventArgs awaitableSocketAsyncEventArgs = Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ?? new AwaitableSocketAsyncEventArgs(this, isReceiveForCaching: true);
3916 awaitableSocketAsyncEventArgs.RemoteEndPoint = remoteEP;
3918 if (valueTask.IsCompleted || !cancellationToken.CanBeCanceled)
3919 {
3920 return valueTask;
3921 }
3924 {
3925 try
3926 {
3927 using (cancellationToken.UnsafeRegister(delegate(object o)
3928 {
3929 CancelConnectAsync((SocketAsyncEventArgs)o);
3930 }, saea))
3931 {
3933 }
3934 }
3935 catch (SocketException ex) when (ex.SocketErrorCode == SocketError.OperationAborted)
3936 {
3937 cancellationToken.ThrowIfCancellationRequested();
3938 throw;
3939 }
3940 }
3941 }
AwaitableSocketAsyncEventArgs _singleBufferReceiveEventArgs
Definition Socket.cs:567
static void CancelConnectAsync(SocketAsyncEventArgs e)
Definition Socket.cs:2966
static int Exchange(ref int location1, int value)
static ValueTask FromCanceled(CancellationToken cancellationToken)
Definition ValueTask.cs:180

References System.Net.Sockets.Socket._singleBufferReceiveEventArgs, System.Net.Sockets.Socket.CancelConnectAsync(), System.cancellationToken, System.Threading.Interlocked.Exchange(), and System.Threading.Tasks.ValueTask< TResult >.FromCanceled().