コード例 #1
0
        public static IObservable <Either <Socket, byte[]> > AcceptObservable(this Socket socket, int receiveSize)
        {
            Contract.Requires(socket != null);
            Contract.Requires(receiveSize >= 0);
            Contract.Ensures(Contract.Result <IObservable <Either <Socket, byte[]> > >() != null);

            var args = new SocketAsyncEventArgs();

            args.SetBuffer(0, receiveSize);

            return(socket
                   .AcceptObservableWithBuffer(args)
                   .Finally(args.Dispose));
        }