11using System ;
2- using System . Collections . Generic ;
32using System . Globalization ;
43using System . Net ;
54using System . Net . Sockets ;
@@ -23,20 +22,18 @@ internal static class PortScanner
2322 /// <param name="scanOperation">The ScanInformation object containing information regarding this scan</param>
2423 /// <returns>A list of LvCheck objects containing information regarding the ports and address that were scanned</returns>
2524 // ReSharper disable once IdentifierTypo
26- internal static List < LvCheck > CheckTCPUDP ( string address , int startPort , int stopPort , int timeout , ScanOperation scanOperation )
25+ internal static void CheckTCPUDP ( string address , int startPort , int stopPort , int timeout , ScanOperation scanOperation )
2726 {
28- List < LvCheck > lv = new List < LvCheck > ( ) ;
2927 for ( int i = startPort ; i <= stopPort ; i ++ )
3028 {
3129 if ( scanOperation . IsCancelled ) break ;
3230
33- lv . AddRange ( CheckTCP ( address , i , i , timeout , scanOperation , false ) ) ;
34- lv . AddRange ( CheckUDP ( address , i , i , timeout , scanOperation , false ) ) ;
31+ CheckTCP ( address , i , i , timeout , scanOperation , false ) ;
32+ CheckUDP ( address , i , i , timeout , scanOperation , false ) ;
3533
3634 scanOperation . Progress . Report ( 1 ) ;
3735 }
3836 scanOperation . ScanCompletedEvent ? . Invoke ( ) ;
39- return lv ;
4037 }
4138
4239 // ReSharper disable once InconsistentNaming
@@ -49,10 +46,8 @@ internal static List<LvCheck> CheckTCPUDP(string address, int startPort, int sto
4946 /// <param name="timeout">The amount of time before the connection times out</param>
5047 /// <param name="scanOperation">The ScanInformation object containing information regarding this scan</param>
5148 /// <param name="reportProgress">A boolean to represent whether this method should report the current progress or not</param>
52- /// <returns>A list of LvCheck objects containing information regarding the ports and address that were scanned</returns>
53- internal static List < LvCheck > CheckTCP ( string address , int startPort , int stopPort , int timeout , ScanOperation scanOperation , bool reportProgress )
49+ internal static void CheckTCP ( string address , int startPort , int stopPort , int timeout , ScanOperation scanOperation , bool reportProgress )
5450 {
55- List < LvCheck > lv = new List < LvCheck > ( ) ;
5651 for ( int i = startPort ; i <= stopPort ; i ++ )
5752 {
5853 if ( scanOperation . IsCancelled ) break ;
@@ -66,7 +61,6 @@ internal static List<LvCheck> CheckTCP(string address, int startPort, int stopPo
6661 Description = IsTcpOpen ( address , i , timeout ) ? "Open" : "Closed" ,
6762 ScanDate = DateTime . Now . ToString ( CultureInfo . CurrentCulture )
6863 } ;
69- lv . Add ( check ) ;
7064
7165 if ( reportProgress )
7266 {
@@ -79,8 +73,6 @@ internal static List<LvCheck> CheckTCP(string address, int startPort, int stopPo
7973 {
8074 scanOperation . ScanCompletedEvent ? . Invoke ( ) ;
8175 }
82-
83- return lv ;
8476 }
8577
8678 // ReSharper disable once InconsistentNaming
@@ -93,10 +85,8 @@ internal static List<LvCheck> CheckTCP(string address, int startPort, int stopPo
9385 /// <param name="timeout">The amount of time before the connection times out</param>
9486 /// <param name="scanOperation">The ScanInformation object containing information regarding this scan</param>
9587 /// <param name="reportProgress">A boolean to represent whether this method should report the current progress or not</param>
96- /// <returns>A list of LvCheck objects containing information regarding the ports and address that were scanned</returns>
97- internal static List < LvCheck > CheckUDP ( string address , int startPort , int stopPort , int timeout , ScanOperation scanOperation , bool reportProgress )
88+ internal static void CheckUDP ( string address , int startPort , int stopPort , int timeout , ScanOperation scanOperation , bool reportProgress )
9889 {
99- List < LvCheck > lv = new List < LvCheck > ( ) ;
10090 for ( int i = startPort ; i <= stopPort ; i ++ )
10191 {
10292 if ( scanOperation . IsCancelled ) break ;
@@ -110,7 +100,6 @@ internal static List<LvCheck> CheckUDP(string address, int startPort, int stopPo
110100 Description = IsUdpOpen ( address , i , timeout ) ? "Open" : "Closed" ,
111101 ScanDate = DateTime . Now . ToString ( CultureInfo . CurrentCulture )
112102 } ;
113- lv . Add ( check ) ;
114103
115104 if ( reportProgress )
116105 {
@@ -123,7 +112,6 @@ internal static List<LvCheck> CheckUDP(string address, int startPort, int stopPo
123112 {
124113 scanOperation . ScanCompletedEvent ? . Invoke ( ) ;
125114 }
126- return lv ;
127115 }
128116
129117
@@ -174,7 +162,7 @@ private static bool IsUdpOpen(string address, int port, int timeout)
174162 byte [ ] sendBytes = new byte [ 4 ] ;
175163 new Random ( ) . NextBytes ( sendBytes ) ;
176164 udpClient . Send ( sendBytes , sendBytes . Length ) ;
177-
165+
178166 IPEndPoint remoteIpEndPoint = new IPEndPoint ( IPAddress . Any , 0 ) ;
179167
180168 byte [ ] result = udpClient . Receive ( ref remoteIpEndPoint ) ;
0 commit comments