1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
//
// MonoTests.Remoting.IpcChannelTests.cs
//
// Authors:
// Robert Jordan (robertj@gmx.net)
//
#if NET_2_0
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
using NUnit.Framework;
namespace MonoTests.Remoting
{
[TestFixture]
public class IpcChannelTest
{
[Test]
public void Bug81653 ()
{
IpcClientChannel c = new IpcClientChannel ();
ChannelDataStore cd = new ChannelDataStore (new string[] { "foo" });
string objectUri;
c.CreateMessageSink (null, cd, out objectUri);
}
[Test]
public void Bug609381 ()
{
string portName = "ipc" + Guid.NewGuid ().ToString ("N");
string objUri = "ipcserver609381.rem";
string url = String.Format ("ipc://{0}/{1}", portName, objUri);
IpcChannel serverChannel = new IpcChannel (portName);
ChannelServices.RegisterChannel (serverChannel);
RemotingServices.Marshal (new Server (), objUri);
Server client = (Server) RemotingServices.Connect (typeof (Server), url);
int count = 10 * 1024 * 1024;
byte[] sendBuf = new byte[count];
sendBuf [sendBuf.Length - 1] = 41;
byte[] recvBuf = client.Send (sendBuf);
Assert.IsNotNull (recvBuf);
Assert.AreNotSame (sendBuf, recvBuf);
Assert.AreEqual (count, recvBuf.Length);
Assert.AreEqual (42, recvBuf [recvBuf.Length - 1]);
sendBuf = null;
recvBuf = null;
ChannelServices.UnregisterChannel (serverChannel);
}
class Server : MarshalByRefObject
{
public byte[] Send (byte[] payload)
{
payload [payload.Length - 1]++;
return payload;
}
}
[Test]
public void TestCtor2 ()
{
string channelName = Guid.NewGuid ().ToString ("N");
string portName = "ipc" + Guid.NewGuid ().ToString ("N");
string url = String.Format ("ipc://{0}/server.rem", portName);
IpcServerChannel chan = new IpcServerChannel (channelName, portName);
string[] uris = chan.GetUrlsForUri ("server.rem");
Assert.IsNotNull (uris);
Assert.Greater (uris.Length, 0);
bool found = false;
foreach (string s in uris) {
if (s == url) {
found = true;
break;
}
}
Assert.IsTrue (found);
}
[Test]
public void TestCtor3 ()
{
string portName = "ipc" + Guid.NewGuid ().ToString ("N");
string url = String.Format ("ipc://{0}/server.rem", portName);
Hashtable props = new Hashtable ();
props ["portName"] = portName;
IpcChannel chan = new IpcChannel (props, null, null);
string[] uris = chan.GetUrlsForUri ("server.rem");
Assert.IsNotNull (uris);
Assert.Greater (uris.Length, 0);
bool found = false;
foreach (string s in uris) {
if (s == url) {
found = true;
break;
}
}
Assert.IsTrue (found);
}
}
}
#endif
|