Client side Remoting Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ME

    #1

    Client side Remoting Question

    In my server app I perform the following:

    //-------------------------------------------
    remoteObject remoteObj = new remoteObject();
    ChannelServices .RegisterChanne l(new TcpChannel(tcpP ort));
    ObjRef refSubManager = RemotingService s.Marshal(remot eObj, "remoteObject") ;

    In the Client app I attempt to do this:
    //--------------------------------------------
    TcpChannel chan = new TcpChannel();
    ChannelServices .RegisterChanne l(chan);
    object obj = (remoteObject) Activator.GetOb ject(typeof(rem oteObject),
    "tcp://" + serverIP + ":" + tcpPort + "/remoteObject");

    remoteObjectLoc al = obj as remoteObject;

    if (remoteObjectLo cal == null)
    {
    MessageBox.Show ("Server is not running");
    }
    else
    {
    MessageBox.Show ("Server is running");
    }


    Trouble is since remoteObjectLoc al is a proxy it NEVER returns null (even if
    the server is not running). How do I tell from the client side that the
    server is serving up the remot object? I can get the proxy when the server
    is running, I just need to verify the server is running before attempting to
    use the proxied object.

    Thanks,

    Matt


  • Bjarke Lindberg

    #2
    Re: Client side Remoting Question

    ME wrote:[color=blue]
    > Trouble is since remoteObjectLoc al is a proxy it NEVER returns null (even if
    > the server is not running). How do I tell from the client side that the
    > server is serving up the remot object? I can get the proxy when the server
    > is running, I just need to verify the server is running before attempting to
    > use the proxied object.[/color]

    Hi Matt.

    Try calling the obj.ToString() It'll throw an exception, if the object
    isn't available (ie. the server is not running).


    /B

    Comment

    Working...