Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DoCloseHandle()

SocketError System.Net.Sockets.SafeSocketHandle.DoCloseHandle ( bool abortive)
inlineprivate

Definition at line 205 of file SafeSocketHandle.cs.

206 {
207 SocketError socketError;
208 if (!abortive)
209 {
210 if (System.Net.NetEventSource.Log.IsEnabled())
211 {
212 System.Net.NetEventSource.Info(this, $"handle:{handle}, Following 'blockable' branch", "DoCloseHandle");
213 }
214 socketError = global::Interop.Winsock.closesocket(handle);
215 if (socketError == SocketError.SocketError)
216 {
217 socketError = (SocketError)Marshal.GetLastWin32Error();
218 }
219 if (System.Net.NetEventSource.Log.IsEnabled())
220 {
221 System.Net.NetEventSource.Info(this, $"handle:{handle}, closesocket()#1:{socketError}", "DoCloseHandle");
222 }
223 if (socketError != SocketError.WouldBlock)
224 {
225 return socketError;
226 }
227 int argp = 0;
228 socketError = global::Interop.Winsock.ioctlsocket(handle, -2147195266, ref argp);
229 if (socketError == SocketError.SocketError)
230 {
231 socketError = (SocketError)Marshal.GetLastWin32Error();
232 }
233 if (System.Net.NetEventSource.Log.IsEnabled())
234 {
235 System.Net.NetEventSource.Info(this, $"handle:{handle}, ioctlsocket()#1:{socketError}", "DoCloseHandle");
236 }
237 if (socketError == SocketError.Success)
238 {
239 socketError = global::Interop.Winsock.closesocket(handle);
240 if (socketError == SocketError.SocketError)
241 {
242 socketError = (SocketError)Marshal.GetLastWin32Error();
243 }
244 if (System.Net.NetEventSource.Log.IsEnabled())
245 {
246 System.Net.NetEventSource.Info(this, $"handle:{handle}, closesocket#2():{socketError}", "DoCloseHandle");
247 }
248 if (socketError != SocketError.WouldBlock)
249 {
250 return socketError;
251 }
252 }
253 }
254 Unsafe.SkipInit(out global::Interop.Winsock.Linger linger);
255 linger.OnOff = 1;
256 linger.Time = 0;
257 socketError = global::Interop.Winsock.setsockopt(handle, SocketOptionLevel.Socket, SocketOptionName.Linger, ref linger, 4);
258 if (socketError == SocketError.SocketError)
259 {
260 socketError = (SocketError)Marshal.GetLastWin32Error();
261 }
262 if (System.Net.NetEventSource.Log.IsEnabled())
263 {
264 System.Net.NetEventSource.Info(this, $"handle:{handle}, setsockopt():{socketError}", "DoCloseHandle");
265 }
266 if (socketError != 0 && socketError != SocketError.InvalidArgument && socketError != SocketError.ProtocolOption)
267 {
268 return socketError;
269 }
270 socketError = global::Interop.Winsock.closesocket(handle);
271 if (System.Net.NetEventSource.Log.IsEnabled())
272 {
273 System.Net.NetEventSource.Info(this, $"handle:{handle}, closesocket#3():{((socketError == SocketError.SocketError) ? ((SocketError)Marshal.GetLastWin32Error()) : socketError)}", "DoCloseHandle");
274 }
275 return socketError;
276 }
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)

References System.Runtime.InteropServices.Marshal.GetLastWin32Error(), System.Runtime.InteropServices.SafeHandle.handle, System.Net.NetEventSource.Info(), and System.Net.NetEventSource.Log.

Referenced by System.Net.Sockets.SafeSocketHandle.CloseHandle().