CSharpTest.Net
Execute Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : Execute Method

input

Glossary Item Box

Sends a message as an array of bytes and retrieves the response from the server, if AuthenticateAs() has not been called, the client will authenticate as Anonymous.

Syntax

Visual Basic (Declaration) 
Public Function Execute( _
   ByVal input() As Byte _
) As Byte()
C# 
public byte[] Execute( 
   byte[] input
)

Parameters

input

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C#Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler = 
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);
        
        server.OnExecute -= handler;
        try 
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NETCopy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys