internal NetSocket() { this.readLock = new object(); this.rawSocket = new Socket( AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.rawSocket.ReceiveBufferSize = NetConfig.SOCKET_BUFFER_SIZE; this.rawSocket.SendBufferSize = NetConfig.SOCKET_BUFFER_SIZE; this.rawSocket.Blocking = false; try { // Ignore port unreachable (connection reset by remote host) const uint IOC_IN = 0x80000000; const uint IOC_VENDOR = 0x18000000; uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; this.rawSocket.IOControl( (int)SIO_UDP_CONNRESET, new byte[] { 0 }, null); } catch { // Not always supported NetDebug.LogWarning( "Failed to set control code for ignoring ICMP port unreachable."); } }
internal NetSocket() { try { // Ignore port unreachable (connection reset by remote host) const uint IOC_IN = 0x80000000; const uint IOC_VENDOR = 0x18000000; var SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; rawSocket.IOControl((int)SIO_UDP_CONNRESET, new byte[] { 0 }, null); } catch { // Not always supported NetDebug.LogWarning("Failed to set control code for ignoring ICMP port unreachable."); } }