Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2008, 10:17 AM
Registered User
 
Join Date: Apr 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to mahen_pali Send a message via Yahoo to mahen_pali
Default Remoting in c#

 Hi to all members
My problem is related to remoting in c#. there are three files
c.cs Customer file code
s.cs Server File Code
o.c Server side code which we call in C.CS

C.CS File
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
public class ccc
{
    public static void Main()
    {
      TcpChannel c = new TcpChannel();
      ChannelServices.RegisterChannel(c);
      zzz a = (zzz)Activator.GetObject(typeof(zzz), "tcp://localhost:8085/eee");
      if (a == null)
          System.Console.WriteLine("Could not locate server");
      else
        Console.WriteLine(a.abc());
    }
}

S.CS
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
public class sss
{
    public static void Main()
    {
          TcpChannel c = new TcpChannel(4444);
          ChannelServices.RegisterChannel(c,true);
          RemotingConfiguration.RegisterWellKnownServiceType (
          Type.GetType("zzz,o"), "eee", WellKnownObjectMode.SingleCall);
          System.Console.WriteLine("Press <enter> to exit...");
          System.Console.ReadLine();
    }
 }


O.CS
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
public class zzz : MarshalByRefObject
{
    public zzz()
    {
        Console.WriteLine("Constructor");
    }
    ~zzz()
    {
        Console.WriteLine("Destructor");
    }
    public String abc()
    {
          Console.WriteLine("Vijay Mukhi2");
          return "Sonal";
    }
  }


When I Comple and execute . it’s compile properly but not execute client code.
Server class execute successfully and give
 o/p Press <enter> to exit...

when I execute client code it’s this error
Unhandled Exception: System.Net.Sockets.SocketException: No connection could be
made because the target machine actively refused it 127.0.0.1:8085

Server stack trace:
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Runtime.Remoting.Channels.RemoteConnection. CreateNewSocket(EndPoint
 ipEndPoint)
   at System.Runtime.Remoting.Channels.RemoteConnection. CreateNewSocket()
   at System.Runtime.Remoting.Channels.SocketCache.GetSo cket(String machinePortA
ndSid, Boolean openNew)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTran sportSink.SendRequestWit
hRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTran sportSink.ProcessMessage
(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITranspor
tHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryClientForma tterSink.SyncProcessMess
age(IMessage msg)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage req
Msg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData& msgDa
ta, Int32 type)
   at zzz.abc()
   at ccc.Main()

My Problem : I am not getting which port I can use for remoting please help me to solve this problem

Thanks


mahendra singh

mahendra singh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Remoting in C# mahen_pali C# 2005 1 February 24th, 2009 05:15 PM
Remoting bhavana .NET Framework 1.x 0 November 12th, 2007 04:20 AM
remoting caribbean Pro VB.NET 2002/2003 0 May 16th, 2006 12:11 PM
Remoting manisha2578 VS.NET 2002/2003 1 June 29th, 2005 06:59 AM
Remoting.... kk_katepally General .NET 0 December 21st, 2004 05:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.