@@ -81,8 +81,10 @@ private void CreateSocket()
81
81
{
82
82
if ( _enableDualMode && _endpoint . Address . Equals ( IPAddress . IPv6Any ) &&
83
83
( string . Equals ( ex . ErrorCode , "AddressFamilyNotSupported" , StringComparison . OrdinalIgnoreCase ) ||
84
- // mono on bsd is throwing this
85
- string . Equals ( ex . ErrorCode , "ProtocolNotSupported" , StringComparison . OrdinalIgnoreCase ) ) )
84
+ // mono 4.8.1 and lower on bsd is throwing this
85
+ string . Equals ( ex . ErrorCode , "ProtocolNotSupported" , StringComparison . OrdinalIgnoreCase ) ||
86
+ // mono 5.2 on bsd is throwing this
87
+ string . Equals ( ex . ErrorCode , "OperationNotSupported" , StringComparison . OrdinalIgnoreCase ) ) )
86
88
{
87
89
_endpoint = new IPEndPoint ( IPAddress . Any , _endpoint . Port ) ;
88
90
_enableDualMode = false ;
@@ -138,6 +140,18 @@ private static void TryCloseAndDispose(Socket socket)
138
140
}
139
141
}
140
142
143
+ private static void TryClose ( Socket socket )
144
+ {
145
+ try
146
+ {
147
+ socket . Close ( ) ;
148
+ }
149
+ catch
150
+ {
151
+
152
+ }
153
+ }
154
+
141
155
private static void Accept ( Socket socket , SocketAsyncEventArgs acceptEventArg , ref Socket accepted )
142
156
{
143
157
// acceptSocket must be cleared since the context object is being reused
@@ -167,17 +181,7 @@ private static void Accept(Socket socket, SocketAsyncEventArgs acceptEventArg, r
167
181
168
182
if ( accepted != null )
169
183
{
170
- try
171
- {
172
- #if NET46
173
- accepted . Close ( ) ;
174
- #else
175
- accepted . Dispose ( ) ;
176
- #endif
177
- }
178
- catch
179
- {
180
- }
184
+ TryClose ( accepted ) ;
181
185
accepted = null ;
182
186
}
183
187
}
@@ -263,6 +267,8 @@ private async void ProcessAccept(Socket accepted)
263
267
return ;
264
268
}
265
269
270
+ _logger . Info ( "HttpEndPointListener.ProcessAccept from {0} secure connection: {1}" , accepted . RemoteEndPoint . ToString ( ) , _secure ) ;
271
+
266
272
HttpConnection conn = new HttpConnection ( _logger , accepted , listener , _secure , _cert , _cryptoProvider , _memoryStreamFactory , _textEncoding , _fileSystem , _environment ) ;
267
273
268
274
await conn . Init ( ) . ConfigureAwait ( false ) ;
@@ -276,6 +282,8 @@ private async void ProcessAccept(Socket accepted)
276
282
}
277
283
catch ( Exception ex )
278
284
{
285
+ TryClose ( accepted ) ;
286
+
279
287
_logger . ErrorException ( "Error in ProcessAccept" , ex ) ;
280
288
}
281
289
}
0 commit comments