开发者

Test if remoting proxy is valid?

I'm using remoting between a client and server, and while it works, I'm seeing some behavior I don't understand.

I'm setting up my server as follows:

        BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
        serverProv.T开发者_高级运维ypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;            
        BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();

        IDictionary props = new Hashtable();
        props["name"] = "MarsLogServer.rem";
        props["port"] = Properties.Settings.Default.ListeningPort;
        props["useIpAddress"] = false;

        server = new LogServer();

        chan = new TcpChannel(props, clientProv, serverProv);
        ChannelServices.RegisterChannel(chan, true);            
        RemotingConfiguration.RegisterWellKnownServiceType(typeof(LogServer), "MarsLogServer.rem", WellKnownObjectMode.Singleton);            

And my client is connecting as follows:

this.logServer = (ILogServer)Activator.GetObject(typeof(ILogServer), connectForm.Url);
this.logServer.AttachClient(this, connectForm.SessionKey)

What's happening is I don't even have the server running, but my call to AttachClient() on the proxy my client receives succeeds. I don't understand why that is, there's no process running hosting an object on the provided URL (unless someone is playing a mean trick on me) so why doesn't it throw an exception?

Ideally I'd like the call to fail, or I'd like some way to test that my proxy is valid before allowing my client to proceed. As it is now there's no way of knowing if the connection was successful or not.


Maybe you could use System.Runtime.Remoting.RemotingServices.IsTransparentProxy(client) to test if the TransparentProxy/RealProxy chain is set up?

-Oisin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜