Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Using Interfaces with .NET Remoting

Using Interfaces with .NET Remoting

Scheduled Pinned Locked Moved C#
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tmagoo
    wrote on last edited by
    #1

    I have created a simple client/server remoting interface that basically allows the client to get a byte array from the server. I am wanting to develop something that will allow the main thread on the server to initialize a byte array and allow the client to access this byte array from the interface. Does anyone have experience doing such a thing? Below is an example of what I want to do; but, don't know how to make it work. Look for initialization and How do I do this within the code comments. using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using RemoteInterfacecls; //Code not proviced at this time using System.Runtime.Serialization; namespace RemotingInterfaceServer { public class dataStuff { public byte [] mystuff; } public class EntryPoint { public static void Main(string[] args) { dataStuff dS = new dataStuff(); //Here is the initializaton ds.mystuff = System.Text.Encoding.ASCII.GetBytes("This is a test"); TcpServerChannel channel = new TcpServerChannel(2566); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteExample), "RemoteExample", WellKnownObjectMode.SingleCall); System.Console.WriteLine("Hit Key to Exit"); System.Console.ReadLine(); } } public class RemoteExample : MarshalByRefObject, IRemoteExample { public RemotingExample() { Console.WriteLine("Constructor Called "); } public IByteArray GetByteArray() { ByteArray byteArray; //This is the from the main initialization // How do I do this ??????????? byteArray.bytesRead = mystuff; return (IByteArray)byteArray; } } [Serializable] public class ByteArray : MarshalByRefObject, IByteArray { public byte [] bytesRead; } Tom McDaniel

    T 1 Reply Last reply
    0
    • T tmagoo

      I have created a simple client/server remoting interface that basically allows the client to get a byte array from the server. I am wanting to develop something that will allow the main thread on the server to initialize a byte array and allow the client to access this byte array from the interface. Does anyone have experience doing such a thing? Below is an example of what I want to do; but, don't know how to make it work. Look for initialization and How do I do this within the code comments. using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using RemoteInterfacecls; //Code not proviced at this time using System.Runtime.Serialization; namespace RemotingInterfaceServer { public class dataStuff { public byte [] mystuff; } public class EntryPoint { public static void Main(string[] args) { dataStuff dS = new dataStuff(); //Here is the initializaton ds.mystuff = System.Text.Encoding.ASCII.GetBytes("This is a test"); TcpServerChannel channel = new TcpServerChannel(2566); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteExample), "RemoteExample", WellKnownObjectMode.SingleCall); System.Console.WriteLine("Hit Key to Exit"); System.Console.ReadLine(); } } public class RemoteExample : MarshalByRefObject, IRemoteExample { public RemotingExample() { Console.WriteLine("Constructor Called "); } public IByteArray GetByteArray() { ByteArray byteArray; //This is the from the main initialization // How do I do this ??????????? byteArray.bytesRead = mystuff; return (IByteArray)byteArray; } } [Serializable] public class ByteArray : MarshalByRefObject, IByteArray { public byte [] bytesRead; } Tom McDaniel

      T Offline
      T Offline
      tmagoo
      wrote on last edited by
      #2

      After many hours of banging my head, I finally realized that the interface should of belonged to the class Entry point. Once I did this, I was able to do what I wanted. Here is a tidbit of the code I used. using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using RemoteInterfacecls; //Code not proviced at this time using System.Runtime.Serialization; namespace RemotingInterfaceServer { public class dataStuff { public byte [] mystuff; } public class EntryPoint { dataStuff dS = new dataStuff(); public static void Main(string[] args) { //Here is the initializaton ds.mystuff = System.Text.Encoding.ASCII.GetBytes("This is a test"); TcpServerChannel channel = new TcpServerChannel(2566); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteExample), "RemoteExample", WellKnownObjectMode.SingleCall); System.Console.WriteLine("Hit Key to Exit"); System.Console.ReadLine(); } public class RemoteExample : MarshalByRefObject, IRemoteExample { public RemotingExample() { Console.WriteLine("Constructor Called "); } public IByteArray GetByteArray() { ByteArray byteArray; byteArray.bytesRead = dS.mystuff; return (IByteArray)byteArray; } } [Serializable] public class ByteArray : MarshalByRefObject, IByteArray { public byte [] bytesRead; } } } Tom McDaniel

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups