System.Net.Sockets.SocketPal.GetLastSocketError C# (CSharp) Метод

GetLastSocketError() публичный статический Метод

public static GetLastSocketError ( ) : SocketError
Результат SocketError
        public static SocketError GetLastSocketError()
        {
            return (SocketError)Marshal.GetLastWin32Error();
        }

Usage Example

        // Check the result of the overlapped operation.
        // Handle synchronous success by completing the asyncResult here.
        // Handle synchronous failure by cleaning up and returning a SocketError.
        internal SocketError ProcessOverlappedResult(bool success, int bytesTransferred)
        {
            if (success)
            {
                // Synchronous success.
                Socket socket = (Socket)AsyncObject;
                if (socket.SafeHandle.SkipCompletionPortOnSuccess)
                {
                    // The socket handle is configured to skip completion on success,
                    // so we can complete this asyncResult right now.
                    CompletionCallback(bytesTransferred, SocketError.Success);
                    return(SocketError.Success);
                }

                // Socket handle is going to post a completion to the completion port (may have done so already).
                // Return pending and we will continue in the completion port callback.
                return(SocketError.IOPending);
            }

            // Get the socket error (which may be IOPending)
            SocketError errorCode = SocketPal.GetLastSocketError();

            if (errorCode == SocketError.IOPending)
            {
                // Operation is pending.
                // We will continue when the completion arrives (may have already at this point).
                return(SocketError.IOPending);
            }

            // Synchronous failure.
            // Release overlapped and pinned structures.
            ReleaseUnmanagedStructures();

            return(errorCode);
        }
All Usage Examples Of System.Net.Sockets.SocketPal::GetLastSocketError