@@ -154,54 +154,6 @@ async Task<bool> TryConnect(IPEndPoint endpoint)
154
154
}
155
155
}
156
156
157
- /// <summary>
158
- /// Try to
159
- /// </summary>
160
- /// <param name="address"></param>
161
- /// <param name="port"></param>
162
- /// <param name="logger"></param>
163
- /// <returns></returns>
164
- public static async Task < IPEndPoint > TryValidateAndConnectAddress2 ( string address , int port , ILogger logger = null )
165
- {
166
- IPEndPoint endpoint = null ;
167
- if ( ! IPAddress . TryParse ( address , out var ipAddress ) )
168
- {
169
- // Try to identify reachable IP address from hostname
170
- var hostEntry = Dns . GetHostEntry ( address ) ;
171
- foreach ( var entry in hostEntry . AddressList )
172
- {
173
- endpoint = new IPEndPoint ( entry , port ) ;
174
- var IsListening = await IsReachable ( endpoint ) ;
175
- if ( IsListening ) break ;
176
- }
177
- }
178
- else
179
- {
180
- // If address is valid create endpoint
181
- endpoint = new IPEndPoint ( ipAddress , port ) ;
182
- }
183
-
184
- async Task < bool > IsReachable ( IPEndPoint endpoint )
185
- {
186
- using ( var tcpClient = new TcpClient ( ) )
187
- {
188
- try
189
- {
190
- await tcpClient . ConnectAsync ( endpoint . Address , endpoint . Port ) ;
191
- logger ? . LogTrace ( "Reachable {ip} {port}" , endpoint . Address , endpoint . Port ) ;
192
- return true ;
193
- }
194
- catch
195
- {
196
- logger ? . LogTrace ( "Unreachable {ip} {port}" , endpoint . Address , endpoint . Port ) ;
197
- return false ;
198
- }
199
- }
200
- }
201
-
202
- return endpoint ;
203
- }
204
-
205
157
/// <summary>
206
158
/// Parse address (hostname) and port to endpoint
207
159
/// </summary>
0 commit comments