@@ -1090,12 +1090,8 @@ private void DualModeSendTo_IPEndPointToHost_Helper(IPAddress connectTo, IPAddre
10901090 using ( Socket client = new Socket ( SocketType . Dgram , ProtocolType . Udp ) )
10911091 using ( SocketUdpServer server = new SocketUdpServer ( _log , listenOn , dualModeServer , out int port ) )
10921092 {
1093- // Send a few packets, in case they aren't delivered reliably.
1094- for ( int i = 0 ; i < ( expectedToTimeout ? 1 : TestSettings . UDPRedundancy ) ; i ++ )
1095- {
1096- int sent = client . SendTo ( new byte [ 1 ] , new IPEndPoint ( connectTo , port ) ) ;
1097- Assert . Equal ( 1 , sent ) ;
1098- }
1093+ int sent = client . SendTo ( new byte [ 1 ] , new IPEndPoint ( connectTo , port ) ) ;
1094+ Assert . Equal ( 1 , sent ) ;
10991095
11001096 bool success = server . WaitHandle . WaitOne ( expectedToTimeout ? TestSettings . FailingTestTimeout : TestSettings . PassingTestTimeout ) ; // Make sure the bytes were received
11011097 if ( ! success )
@@ -1189,14 +1185,10 @@ private void DualModeBeginSendTo_EndPointToHost_Helper(IPAddress connectTo, IPAd
11891185 using ( Socket client = new Socket ( SocketType . Dgram , ProtocolType . Udp ) )
11901186 using ( SocketUdpServer server = new SocketUdpServer ( _log , listenOn , dualModeServer , out int port ) )
11911187 {
1192- // Send a few packets, in case they aren't delivered reliably.
1193- for ( int i = 0 ; i < ( expectedToTimeout ? 1 : TestSettings . UDPRedundancy ) ; i ++ )
1194- {
1195- IAsyncResult async = client . BeginSendTo ( new byte [ 1 ] , 0 , 1 , SocketFlags . None , new IPEndPoint ( connectTo , port ) , null , null ) ;
1188+ IAsyncResult async = client . BeginSendTo ( new byte [ 1 ] , 0 , 1 , SocketFlags . None , new IPEndPoint ( connectTo , port ) , null , null ) ;
11961189
1197- int sent = client . EndSendTo ( async ) ;
1198- Assert . Equal ( 1 , sent ) ;
1199- }
1190+ int sent = client . EndSendTo ( async ) ;
1191+ Assert . Equal ( 1 , sent ) ;
12001192
12011193 bool success = server . WaitHandle . WaitOne ( expectedToTimeout ? TestSettings . FailingTestTimeout : TestSettings . PassingTestTimeout ) ; // Make sure the bytes were received
12021194 if ( ! success )
@@ -1311,28 +1303,24 @@ private void DualModeSendToAsync_IPEndPointToHost_Helper(IPAddress connectTo, IP
13111303 using ( Socket client = new Socket ( SocketType . Dgram , ProtocolType . Udp ) )
13121304 using ( SocketUdpServer server = new SocketUdpServer ( _log , listenOn , dualModeServer , out int port ) )
13131305 {
1314- // Send a few packets, in case they aren't delivered reliably.
1315- for ( int i = 0 ; i < ( expectedToTimeout ? 1 : TestSettings . UDPRedundancy ) ; i ++ )
1306+ using ( ManualResetEvent waitHandle = new ManualResetEvent ( false ) )
13161307 {
1317- using ( ManualResetEvent waitHandle = new ManualResetEvent ( false ) )
1308+ SocketAsyncEventArgs args = new SocketAsyncEventArgs ( ) ;
1309+ args . RemoteEndPoint = new IPEndPoint ( connectTo , port ) ;
1310+ args . SetBuffer ( new byte [ 1 ] , 0 , 1 ) ;
1311+ args . UserToken = waitHandle ;
1312+ args . Completed += AsyncCompleted ;
1313+
1314+ bool async = client . SendToAsync ( args ) ;
1315+ if ( async)
13181316 {
1319- SocketAsyncEventArgs args = new SocketAsyncEventArgs ( ) ;
1320- args . RemoteEndPoint = new IPEndPoint ( connectTo , port ) ;
1321- args . SetBuffer ( new byte [ 1 ] , 0 , 1 ) ;
1322- args . UserToken = waitHandle ;
1323- args . Completed += AsyncCompleted ;
1324-
1325- bool async = client . SendToAsync ( args ) ;
1326- if ( async)
1327- {
1328- Assert . True ( waitHandle . WaitOne ( TestSettings . PassingTestTimeout ) , "Timeout while waiting for connection" ) ;
1329- }
1330-
1331- Assert . Equal ( 1 , args . BytesTransferred ) ;
1332- if ( args . SocketError != SocketError . Success )
1333- {
1334- throw new SocketException ( ( int ) args . SocketError ) ;
1335- }
1317+ Assert . True ( waitHandle . WaitOne ( TestSettings . PassingTestTimeout ) , "Timeout while waiting for connection" ) ;
1318+ }
1319+
1320+ Assert . Equal ( 1 , args . BytesTransferred ) ;
1321+ if ( args . SocketError != SocketError . Success )
1322+ {
1323+ throw new SocketException ( ( int ) args . SocketError ) ;
13361324 }
13371325 }
13381326
@@ -1605,7 +1593,7 @@ private void BeginReceiveFrom_Helper(IPAddress listenOn, IPAddress connectTo, bo
16051593 // Assert.Equal(AddressFamily.InterNetworkV6, remoteEndPoint.AddressFamily);
16061594 // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address);
16071595
1608- SocketUdpClient client = new SocketUdpClient ( _log , serverSocket , connectTo , port , redundant : ! expectedToTimeout ) ;
1596+ SocketUdpClient client = new SocketUdpClient ( _log , serverSocket , connectTo , port ) ;
16091597 bool success = async . AsyncWaitHandle . WaitOne ( expectedToTimeout ? TestSettings . FailingTestTimeout : TestSettings. PassingTestTimeout) ;
16101598 if ( ! success )
16111599 {
@@ -1750,7 +1738,7 @@ private void ReceiveFromAsync_Helper(IPAddress listenOn, IPAddress connectTo, bo
17501738 args . Completed += AsyncCompleted ;
17511739
17521740 bool async = serverSocket . ReceiveFromAsync ( args ) ;
1753- SocketUdpClient client = new SocketUdpClient ( _log , serverSocket , connectTo , port , redundant : ! expectedToTimeout ) ;
1741+ SocketUdpClient client = new SocketUdpClient ( _log , serverSocket , connectTo , port ) ;
17541742 if ( async & & ! waitHandle . WaitOne ( expectedToTimeout ? TestSettings . FailingTestTimeout : TestSettings . PassingTestTimeout ) )
17551743 {
17561744 throw new TimeoutException ( ) ;
@@ -1978,10 +1966,7 @@ public void ReceiveMessageFromAsync_SocketAsyncEventArgs_Success(bool ipv4)
19781966 var ep = new IPEndPoint ( loopback , receiverPort ) ;
19791967 for ( int iters = 0 ; iters < 5 ; iters ++ )
19801968 {
1981- for ( int i = 0 ; i < TestSettings . UDPRedundancy ; i ++ )
1982- {
1983- sender . SendTo ( new byte [ DataLength ] , ep ) ;
1984- }
1969+ sender . SendTo ( new byte [ DataLength ] , ep ) ;
19851970
19861971 if ( ! receiver . ReceiveMessageFromAsync ( args ) )
19871972 {
@@ -2203,7 +2188,7 @@ private void BeginReceiveMessageFrom_Helper(IPAddress listenOn, IPAddress connec
22032188 // Assert.Equal(AddressFamily.InterNetworkV6, remoteEndPoint.AddressFamily);
22042189 // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address);
22052190
2206- SocketUdpClient client = new SocketUdpClient ( _log , serverSocket , connectTo , port , redundant : ! expectedToTimeout ) ;
2191+ SocketUdpClient client = new SocketUdpClient ( _log , serverSocket , connectTo , port ) ;
22072192 bool success = async . AsyncWaitHandle . WaitOne ( expectedToTimeout ? TestSettings . FailingTestTimeout : TestSettings. PassingTestTimeout) ;
22082193 if ( ! success )
22092194 {
@@ -2378,7 +2363,7 @@ private void ReceiveMessageFromAsync_Helper(IPAddress listenOn, IPAddress connec
23782363 bool async = serverSocket . ReceiveMessageFromAsync ( args ) ;
23792364 Assert . True ( async ) ;
23802365
2381- SocketUdpClient client = new SocketUdpClient ( _log , serverSocket , connectTo , port , redundant : ! expectedToTimeout ) ;
2366+ SocketUdpClient client = new SocketUdpClient ( _log , serverSocket , connectTo , port ) ;
23822367 if ( ! waitHandle . WaitOne ( serverSocket . ReceiveTimeout ) )
23832368 {
23842369 throw new TimeoutException ( ) ;
@@ -2708,7 +2693,7 @@ protected class SocketUdpClient
27082693 private IPAddress _connectTo ;
27092694 private Socket _serverSocket ;
27102695
2711- public SocketUdpClient ( ITestOutputHelper output , Socket serverSocket , IPAddress connectTo , int port , bool redundant = true , bool sendNow = true )
2696+ public SocketUdpClient ( ITestOutputHelper output , Socket serverSocket , IPAddress connectTo , int port , bool sendNow = true )
27122697 {
27132698 _output = output ;
27142699
@@ -2718,25 +2703,22 @@ public SocketUdpClient(ITestOutputHelper output, Socket serverSocket, IPAddress
27182703
27192704 if ( sendNow )
27202705 {
2721- Task . Run ( ( ) => ClientSend ( redundant ) ) ;
2706+ Task . Run ( ( ) => ClientSend ( ) ) ;
27222707 }
27232708 }
27242709
2725- public void ClientSend ( bool redundant = true , int timeout = 3 )
2710+ public void ClientSend ( int timeout = 3 )
27262711 {
27272712 try
27282713 {
27292714 Socket socket = new Socket ( _connectTo . AddressFamily , SocketType . Dgram , ProtocolType . Udp ) ;
27302715 socket . SendTimeout = timeout * 1000 ;
27312716
2732- for ( int i = 0 ; i < ( redundant ? TestSettings . UDPRedundancy : 1 ) ; i ++ )
2733- {
2734- SocketAsyncEventArgs e = new SocketAsyncEventArgs ( ) ;
2735- e . RemoteEndPoint = new IPEndPoint ( _connectTo , _port ) ;
2736- e . SetBuffer ( new byte [ 1 ] , 0 , 1 ) ;
2717+ SocketAsyncEventArgs e = new SocketAsyncEventArgs ( ) ;
2718+ e . RemoteEndPoint = new IPEndPoint ( _connectTo , _port ) ;
2719+ e . SetBuffer ( new byte [ 1 ] , 0 , 1 ) ;
27372720
2738- socket . SendToAsync ( e ) ;
2739- }
2721+ socket . SendToAsync ( e ) ;
27402722 }
27412723 catch ( SocketException e )
27422724 {
0 commit comments