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

Glossary Item Box

Stops listening for this instance, if this is the last instance to stop listening the process stops listening on all registered protocols.

Syntax

Visual Basic (Declaration) 
Public Sub StopListening() 
C# 
public void StopListening()

Example

RpcLibrary/RpcLibrary.Test/TestClientApi.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();
    server.OnExecute +=
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    {
        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);
        client.Execute(new byte[0]);
        client = null;
    }

    GC.Collect(0, GCCollectionMode.Forced);
    GC.WaitForPendingFinalizers();

    server.StopListening();
}
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()
    server.OnExecute += Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    If True Then
        Dim 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)
        client.Execute(New Byte(0) {})
        client = Nothing
    End If

    GC.Collect(0, GCCollectionMode.Forced)
    GC.WaitForPendingFinalizers()

    server.StopListening()
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