private static void TestSendReceiveRequest( Action<IPEndPoint, UdpServerTransportManager> 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 UdpServerTransportManager( server ) )
			{
				test( endPoint, transportManager );
			}
		}
		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 UdpServerTransportManager( server ) )
				{
					test( endPoint, arrivalLatch, arriveds );
				}
			}
		}
		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 UdpServerTransportManager( server ) )
			{
				Socket listeningSocket = null;
				target.GetListeningSocket( ref listeningSocket );
				Assert.That( listeningSocket.GetSocketOption( SocketOptionLevel.IPv6, SocketOptionName.IPv6Only ), Is.EqualTo( 0 ) );
			}
		}
Exemple #4
0
		/// <summary>
		///		Initializes a new instance of the <see cref="UdpServerTransport"/> 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 UdpServerTransport( UdpServerTransportManager manager ) : base( manager ) { }