[Mono-list] Bi-directional remoting
Steve Mentzer
steve.mentzer@mullinconsulting.com
Fri, 21 Feb 2003 13:49:37 -0800
... which is also why this won't work when the client is behind a =
firewall or nat'ing device.
because of this little detail, it renders the technology almost useless. =
:)
-----Original Message-----
From: Lluis Sanchez [mailto:lluis@ideary.com]
Sent: Friday, February 21, 2003 12:30 PM
To: Bawcom, Aaron; Urs Muff; mono-list@lists.ximian.com
Subject: Re: [Mono-list] Bi-directional remoting
Correct. The client TcpChannel starts a listener using any free port. =
This
port info is added to the object reference sent to the server. When the
server calls a method of that object, it creates a new direct connection =
to
the client.
----- Original Message -----
From: "Bawcom, Aaron" <aaron_bawcom@intrusion.com>
To: "'Lluis Sanchez'" <lluis@ideary.com>; "Urs Muff" <umuff@quark.com>;
<mono-list@lists.ximian.com>
Sent: Friday, February 21, 2003 9:14 PM
Subject: RE: [Mono-list] Bi-directional remoting
> This creates an entirely new TCP connection right? It doesn't use the
> existing TCP session already in place correct?
>
> -----Original Message-----
> From: Lluis Sanchez [mailto:lluis@ideary.com]
> Sent: Friday, February 21, 2003 12:51 PM
> To: Urs Muff; mono-list@lists.ximian.com
> Subject: Re: [Mono-list] Bi-directional remoting
>
>
> Bi-directional remotingHi,
>
> In the client configuration file change <channel ref=3D"tcp"> to =
<channel
> ref=3D"tcp" port=3D"0">. This will create a tcp listener in the client
(however,
> in mono configuration files don't work yet).
>
> Lluis.
>
> ----- Original Message -----
> From: Urs Muff
> To: 'mono-list@lists.ximian.com'
> Sent: Friday, February 21, 2003 7:26 PM
> Subject: [Mono-list] Bi-directional remoting
>
>
> How would you create such a bi-directional channel? All the samples I
used
> so far are only server-client, but not the other way around. I have a
> delegate that I want to implement on the client side. The class
> implementing the callback sits on the client (of course). I even use =
the
> common abstract pattern described by a Microsoft KB article, but still =
no
> luck. Debug output: ASP.Net Server starting Server.Do start An =
unhandled
> exception of type 'System.Runtime.Remoting.RemotingException'
> occurred in mscorlib.dll
> Additional information: This remoting proxy has no channel sink which
means
> either the server has no registered server channels that are =
listening, or
> this application has no suitable client channel to talk to the server.
>
>
> Here is the sample code:
>
>
> CommonLib: [both server and client have access]
> -----------------------------------------------
> using System;
> using System.Runtime.Remoting;
> public delegate void BaseEventHandler(object sender,RemoteEventArgs =
e);
> [Serializable] public class RemoteEventArgs : EventArgs {
> public static new RemoteEventArgs Empty =3D new =
RemoteEventArgs(); }
> public abstract class RemoteCallback : MarshalByRefObject {
> [System.Runtime.Remoting.Messaging.OneWay]
> public void Callback(object sender,RemoteEventArgs e)
> {
> CallbackImpl(sender,e);
> }
> protected abstract void CallbackImpl(object =
sender,RemoteEventArgs
> e); } public interface IServer {
> event BaseEventHandler Evt;
> void Do();
> }
>
>
> ASP.Net Server:
> --------------------------------------------
> class S : MarshalByRefObject, IServer
> {
> public event BaseEventHandler Evt;
> public void Do()
> {
> System.Diagnostics.Debug.WriteLine("Server.Do start");
> if (Evt !=3D null) Evt(this,RemoteEventArgs.Empty);
> System.Diagnostics.Debug.WriteLine("Server.Do end");
> }
> }
> public class Service1 : System.Web.Services.WebService
> {
> ... // standard web service stuff (autogenerated)
> static bool Init =3D false;
> [WebMethod]
> public void StartUp()
> {
> if (!Init)
> {
> =
RemotingConfiguration.Configure("/Server.config");
> Init =3D true;
> }
> System.Diagnostics.Debug.WriteLine("ASP.Net Server
> starting");
> }
> }
> <configuration>
> <system.runtime.remoting>
> <application>
> <service>
> <wellknown
> mode=3D"Singleton"
> type=3D"S, Server"
> objectUri=3D"S"
> />
> </service>
> <channels>
> <channel ref=3D"tcp" port=3D"8085">
> <serverProviders>
> <formatter ref=3D"binary"/>
> </serverProviders>
> </channel>
> </channels>
> </application>
> </system.runtime.remoting>
> </configuration>
> Client:
> --------------------------------------------
> using System;
> using System.Runtime.Remoting;
> public class Test
> {
> static void Main()
> {
> =
RemotingConfiguration.Configure("../../Client.config");
>
> new Client.localhost.Service1().StartUp();
> IServer s =3D
> Activator.GetObject(typeof(IServer),"tcp://localhost:8085/S") as =
IServer;
> s.Evt +=3D new BaseEventHandler(
> new ClientChangedCallback().Callback);
> s.Do();
> System.Diagnostics.Debug.WriteLine("I never get =
here");
> }
> }
> public class ClientChangedCallback : RemoteCallback
> {
> protected override void CallbackImpl(object =
sender,RemoteEventArgs
> e)
> {
> System.Diagnostics.Debug.WriteLine("And of course I =
never
> get here");
> }
> }
> <configuration>
> <system.runtime.remoting>
> <application>
> <channels>
> <channel ref=3D"tcp">
> <clientProviders>
> <formatter ref=3D"binary"/>
> </clientProviders>
> </channel>
> </channels>
> </application>
> </system.runtime.remoting>
> </configuration>
>
> _______________________________________________
> Mono-list maillist - Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
_______________________________________________
Mono-list maillist - Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list