System.Net.Sockets.Socket.UnsafeBeginConnect C# (CSharp) Method

UnsafeBeginConnect() private method

private UnsafeBeginConnect ( EndPoint remoteEP, AsyncCallback callback, object state, bool flowContext = false ) : IAsyncResult
remoteEP EndPoint
callback AsyncCallback
state object
flowContext bool
return IAsyncResult
        internal IAsyncResult UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, object state, bool flowContext = false)
        {
            if (CanUseConnectEx(remoteEP))
            {
                return BeginConnectEx(remoteEP, flowContext, callback, state);
            }

            EndPoint endPointSnapshot = remoteEP;
            var asyncResult = new ConnectAsyncResult(this, endPointSnapshot, state, callback);

            // For connectionless protocols, Connect is not an I/O call.
            Connect(remoteEP);
            asyncResult.FinishPostingAsyncOp();

            // Synchronously complete the I/O and call the user's callback.
            asyncResult.InvokeCallback();
            return asyncResult;
        }