That is exactly what I thought! So here is some of the source code (after bit of copy and pasting...):
-- contract definition
[ServiceContract(CallbackContract = typeof(IAliveCallback))]
public interface IAlive
{
[OperationContract]
bool Validate();
[OperationContract]
string AliveWait(int i); // test test
}
-- implementing the contract in my Alive class
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)]
public class Alive : SymHostBase, IAlive
{
private readonly static string _ID = "Alive";
private static int _MaxAliveWaitSeconds = 5;
public bool Validate()
{
return true;
}
public string AliveWait(int i)
{
Thread.Sleep(i * 1000);
return string.Format("I waited {0} seconds", i);
}
...
...
}
-- then on the Host app it looks like this...
string s = string.Format("net.tcp://localhost:{0}/Host/", port);
Uri tcpAddr = new Uri(s);
Uri[] baseAddress = { tcpAddr };
int MaxBuffer = 64; // 64 Mb
int bufferSize = MaxBuffer * 1024 * 1024; // 67108864
NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.None, true);
tcpBinding.MaxBufferPoolSize = bufferSize; // 64 Mb
tcpBinding.MaxBufferSize = bufferSize;
tcpBinding.MaxReceivedMessageSize = bufferSize;
tcpBinding.TransferMode = TransferMode.Buffered;
tcpBinding.ReaderQuotas.MaxArrayLength = bufferSize;
tcpBinding.ReaderQuotas.MaxBytesPerRead = bufferSize;
tcpBinding.ReaderQuotas.MaxStringContentLength = bufferSize;
tcpBinding.MaxConnections = 100;
//tcpBinding.ReceiveTimeout = new TimeSpan(20, 0, 0);
tcpBinding.SendTimeout = new TimeSpan(0, 0, 5);
tcpBinding.ReliableSession.Enabled = true;
tcpBinding.ReliableSession.InactivityTimeout = new TimeSpan(7, 0, 0, 0); // 7 days
_HostAlive = new ServiceHost(typeof(Alive), baseAddress);
_HostAlive.AddServiceEndpoint(typeof(IAlive), tcpBinding, "alive"); // tcpBinding
ServiceThrottlingBehavior throttle = _HostAlive.Description.Behaviors.Find<ServiceThrottlingBehavior>();
if (throttle == null)
{
throttle = new ServiceThrottlingBehavior();
host.Description.Behaviors.Add(throttle);
}
throttle.MaxConcurrentCalls = 1000; // default 16
throttle.MaxConcurrentInstances = 1000; // default 26
throttle.MaxConcurrentSessions = 1000; // default 10
// open the host - bring it into life!
host.Open();