当前位置: 首页>>代码示例>>C#>>正文


C# SocketAsyncEventArgs.InvokeAsync方法代码示例

本文整理汇总了C#中System.Net.Sockets.SocketAsyncEventArgs.InvokeAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SocketAsyncEventArgs.InvokeAsync方法的具体用法?C# SocketAsyncEventArgs.InvokeAsync怎么用?C# SocketAsyncEventArgs.InvokeAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Sockets.SocketAsyncEventArgs的用法示例。


在下文中一共展示了SocketAsyncEventArgs.InvokeAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisconnectObservable

        /// <summary>
        /// Closes the socket connection and allows reuse of the <paramref name="socket"/>.
        /// </summary>
        /// <param name="socket">The socket that will be disconnected.</param>
        /// <param name="eventArgs">The <see cref="SocketAsyncEventArgs"/> object to use for this asynchronous socket operation.</param>
        /// <returns>A singleton observable sequence containing the result of the operation.</returns>
        /// <seealso href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.disconnectasync.aspx">Socket.DisconnectAsync</seealso>
        public static IObservable<SocketAsyncEventArgs> DisconnectObservable(this Socket socket, SocketAsyncEventArgs eventArgs)
        {
            Contract.Requires(socket != null);
            Contract.Requires(eventArgs != null);
            Contract.Ensures(Contract.Result<IObservable<SocketAsyncEventArgs>>() != null);

            return eventArgs.InvokeAsync(socket.DisconnectAsync);
        }
开发者ID:Gohla,项目名称:ReactiveIRC,代码行数:15,代码来源:SocketExtensions+-+Connection.cs

示例2: ReceiveMessageFromObservable

        /// <summary>
        /// Receives data from a bound <see cref="Socket"/>.
        /// </summary>
        /// <param name="socket">The socket that will receive the data.</param>
        /// <param name="eventArgs">The <see cref="SocketAsyncEventArgs"/> object to use for this asynchronous socket operation.</param>
        /// <returns>A singleton observable sequence containing the result of the operation.</returns>
        /// <seealso href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.receivemessagefromasync.aspx">Socket.ReceiveMessageFromAsync</seealso>
        public static IObservable<SocketAsyncEventArgs> ReceiveMessageFromObservable(this Socket socket, SocketAsyncEventArgs eventArgs)
        {
            Contract.Requires(socket != null);
            Contract.Requires(eventArgs != null);
            Contract.Ensures(Contract.Result<IObservable<SocketAsyncEventArgs>>() != null);

            return eventArgs.InvokeAsync(socket.ReceiveMessageFromAsync);
        }
开发者ID:wasabii,项目名称:rnet,代码行数:15,代码来源:SocketExtensions.cs

示例3: Connect

    /// <summary>
    /// Establishes a connection to a remote host.
    /// </summary>
    /// <param name="socketType">One of the <see cref="SocketType"/> values.</param>
    /// <param name="protocolType">One of the <see cref="ProtocolType"/> values.</param>
    /// <param name="eventArgs">The <see cref="SocketAsyncEventArgs"/> object to use for this asynchronous socket operation.</param>
    /// <returns>A singleton observable sequence containing the result of the operation.</returns>
    /// <seealso href="http://msdn.microsoft.com/en-us/library/cc422500.aspx">Socket.ConnectAsync</seealso>
    public static IObservable<SocketAsyncEventArgs> Connect(
      SocketType socketType,
      ProtocolType protocolType,
      SocketAsyncEventArgs eventArgs)
    {
      Contract.Requires(eventArgs != null);
      Contract.Ensures(Contract.Result<IObservable<SocketAsyncEventArgs>>() != null);

      return eventArgs.InvokeAsync(e => Socket.ConnectAsync(socketType, protocolType, e));
    }
开发者ID:ibebbs,项目名称:Rxx,代码行数:18,代码来源:ObservableSocket+-+Connection.cs


注:本文中的System.Net.Sockets.SocketAsyncEventArgs.InvokeAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。