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

◆ CreateSocket() [1/2]

static SocketError System.Net.Sockets.SocketPal.CreateSocket ( AddressFamily addressFamily,
SocketType socketType,
ProtocolType protocolType,
out SafeSocketHandle socket )
inlinestatic

Definition at line 27 of file SocketPal.cs.

28 {
29 global::Interop.Winsock.EnsureInitialized();
30 IntPtr preexistingHandle = global::Interop.Winsock.WSASocketW(addressFamily, socketType, protocolType, IntPtr.Zero, 0u, global::Interop.Winsock.SocketConstructorFlags.WSA_FLAG_OVERLAPPED | global::Interop.Winsock.SocketConstructorFlags.WSA_FLAG_NO_HANDLE_INHERIT);
31 socket = new SafeSocketHandle(preexistingHandle, ownsHandle: true);
32 if (socket.IsInvalid)
33 {
34 SocketError lastSocketError = GetLastSocketError();
35 if (System.Net.NetEventSource.Log.IsEnabled())
36 {
37 System.Net.NetEventSource.Error(null, $"WSASocketW failed with error {lastSocketError}", "CreateSocket");
38 }
39 socket.Dispose();
40 return lastSocketError;
41 }
42 if (System.Net.NetEventSource.Log.IsEnabled())
43 {
44 System.Net.NetEventSource.Info(null, socket, "CreateSocket");
45 }
46 return SocketError.Success;
47 }
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static SocketError GetLastSocketError()
Definition SocketPal.cs:22

References System.Net.NetEventSource.Error(), System.Net.Sockets.SocketPal.GetLastSocketError(), System.Net.NetEventSource.Info(), System.Net.NetEventSource.Log, and System.IntPtr.Zero.

Referenced by System.Net.Sockets.Socket.Socket(), and System.Net.Sockets.Socket.Socket().