private static void TestSendNotify(int concurrency, Action <IPEndPoint, CountdownEvent, IProducerConsumerCollection <string> > test) { var endPoint = new IPEndPoint(IPAddress.Loopback, 57319); var config = new RpcServerConfiguration(); config.BindingEndPoint = endPoint; using (var arrivalLatch = new CountdownEvent(concurrency)) { var arriveds = new ConcurrentQueue <string>(); config.DispatcherProvider = s => new CallbackDispatcher( s, (id, args) => { arriveds.Enqueue(args[0].ToString()); arrivalLatch.Signal(); return(args); } ); config.PreferIPv4 = true; using (var server = new RpcServer(config)) using (var transportManager = new TcpServerTransportManager(server)) { test(endPoint, arrivalLatch, arriveds); } } }
private static void TestSendReceiveRequest(Action <IPEndPoint, TcpServerTransportManager> test) { var endPoint = new IPEndPoint(IPAddress.Loopback, 57319); var config = new RpcServerConfiguration(); config.BindingEndPoint = endPoint; config.DispatcherProvider = s => new CallbackDispatcher( s, (id, args) => args ); config.PreferIPv4 = true; using (var server = new RpcServer(config)) using (var transportManager = new TcpServerTransportManager(server)) { test(endPoint, transportManager); } }
public void TestListen_NotIPv6OnlyOnWinNT6OrLator() { if (Environment.OSVersion.Platform != PlatformID.Win32NT || Environment.OSVersion.Version.Major < 6) { Assert.Ignore("This test can be run on WinNT 6 or later."); } var config = new RpcServerConfiguration() { PreferIPv4 = false }; using (var server = new RpcServer()) using (var target = new TcpServerTransportManager(server)) { Socket listeningSocket = null; target.GetListeningSocket(ref listeningSocket); Assert.That(listeningSocket.GetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only), Is.EqualTo(0)); } }
/// <summary> /// Initializes a new instance of the <see cref="TcpServerTransport"/> class. /// </summary> /// <param name="manager">The manager which will manage this instance.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="manager"/> is <c>null</c>. /// </exception> public TcpServerTransport(TcpServerTransportManager manager) : base(manager) { }