int port;
TcpClient tcpclient;
+ Stream network_stream;
public SimpleClientTransportSink (string url)
{
out Stream responseStream)
{
// get a network stream
- tcpclient.Connect (host, port);
- Stream network_stream = tcpclient.GetStream ();
-
+ if (network_stream == null) {
+ tcpclient.Connect (host, port);
+ network_stream = tcpclient.GetStream ();
+ }
+
// send the message
SimpleMessageFormat.SendMessageStream (network_stream, (MemoryStream)requestStream,
SimpleMessageFormat.MessageType.Request,
MemoryStream mem_stream = SimpleMessageFormat.ReceiveMessageStream (network_stream, out msg_type, out uri);
// close the stream
- tcpclient.Close ();
+ //tcpclient.Close ();
switch (msg_type) {
case SimpleMessageFormat.MessageType.Response:
void WaitForConnections ()
{
+ TcpClient client = listener.AcceptTcpClient ();
+ Stream network_stream = client.GetStream ();
+
while (true) {
- TcpClient client = listener.AcceptTcpClient ();
- sink.InternalProcessMessage (client.GetStream ());
+ sink.InternalProcessMessage (network_stream);
- client.Close ();
}
}
//
using System;
+using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.CompilerServices;
public abstract class RealProxy {
Type class_to_proxy;
-
- protected RealProxy () {
+
+ protected RealProxy ()
+ {
throw new NotImplementedException ();
}
- protected RealProxy (Type classToProxy) {
+ protected RealProxy (Type classToProxy)
+ {
this.class_to_proxy = classToProxy;
}
- protected RealProxy (Type classToProxy, IntPtr stub, object stubData) {
+ protected RealProxy (Type classToProxy, IntPtr stub, object stubData)
+ {
throw new NotImplementedException ();
}
+ public virtual ObjRef CreateObjRef (Type requestedType)
+ {
+ throw new NotImplementedException ();
+ }
+
public abstract IMessage Invoke (IMessage msg);
/* this is called from unmanaged code */
IMessageSink sink;
-
public RemotingProxy (Type type, IMessageSink sink) : base (type)
{
this.sink = sink;
2002-09-03 Dietmar Maurer <dietmar@ximian.com>
+ * RemotingServices.cs: add an unique app_id string used to generate
+ unique object uris.
+
* ObjRef.cs: added serialization support
2002-08-31 Dietmar Maurer <dietmar@ximian.com>
throw new RemotingException ("Cannot create channel sink");
RemotingProxy real_proxy = new RemotingProxy (type, sink);
-
+
return real_proxy.GetTransparentProxy ();
}
{
public sealed class RemotingServices {
+ internal static string app_id;
+
+ static RemotingServices ()
+ {
+ app_id = "/" + Guid.NewGuid().ToString().Replace('-', '_') + "/";
+
+ }
+
+ static int next_id = 1;
+
private RemotingServices () {}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
return svr.GetType ();
}
+ public static string GetObjectUri (MarshalByRefObject obj)
+ {
+ throw new NotImplementedException ();
+ }
+
static Hashtable uri_hash = new Hashtable ();
private static void RegisterServerForUri (MarshalByRefObject obj, string uri)
static Mutex mtx = new Mutex ();
+ public static ObjRef Marshal (MarshalByRefObject obj)
+ {
+ string uri = app_id + Environment.TickCount + "_" + next_id++;
+ return Marshal (obj, uri, null);
+ }
+
public static ObjRef Marshal (MarshalByRefObject obj, string uri)
{
return Marshal (obj, uri, null);
RegisterServerForUri (obj, uri);
}
- res = obj.CreateObjRef (type);
+ // res = obj.CreateObjRef (type);
+ res = new ObjRef (obj, type);
res.URI = uri;
} finally {
// Evidence evidence;
- private AppDomain () {}
-
+ AppDomain () {}
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern AppDomainSetup getSetup ();
public virtual ObjRef CreateObjRef (Type type)
{
- return new ObjRef (this, type);
+ throw new NotImplementedException ();
}
public object GetLifetimeService ()