[Mono-list] Large messages over NetTcpBinding
wuffus
w.schwarz at odoscope.com
Fri Nov 11 06:48:53 EST 2011
Yes, it runs under Windows.
Here a minimal example:
Server:
using System;
using System.IO;
using System.ServiceModel;
namespace nettcptest
{
[ServiceContract]
interface ITest
{
[OperationContract]
Stream test();
}
public class Test : ITest
{
public Stream test()
{
byte[] b=new byte[100000];
MemoryStream str = new MemoryStream(b);
return str;
}
}
class Program
{
static void Main(string[] args)
{
Uri uri = new Uri("net.tcp://localhost:3000");
ServiceHost host = new ServiceHost(typeof(Test),uri);
host.Open();
Console.Read();
}
}
}
Client:
using System.IO;
using System.ServiceModel;
namespace nettcptestClient
{
class Program
{
[ServiceContract]
interface ITest
{
[OperationContract]
Stream test();
}
static void Main(string[] args)
{
var binding=new NetTcpBinding();
binding.MaxReceivedMessageSize = 1000000;
ChannelFactory<ITest> factory =
new ChannelFactory<ITest>(binding, new
EndpointAddress("net.tcp://localhost:3000"));
ITest client = factory.CreateChannel();
((IClientChannel)client).Closed += delegate { factory.Close();
};
client.test();
}
}
}
--
View this message in context: http://mono.1490590.n4.nabble.com/Large-messages-over-NetTcpBinding-tp4016272p4031156.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list