/
githubmirror
/
shadowsocks-windows
Обзор
Документация
Войти
/
githubmirror
/
shadowsocks-windows
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v4
shadowsocks-csharp/Util/Sockets/SocketUtil.cs
65 строк
1 KB
Rajan
Socket.Close calls Socket.Dispose internally
17 авг 2018, 19:48
Не верифицирован
17 авг 2018, 19:48
ee11e3c
Код
Авторство
О чём код?
using System; using System.Net; using System.Net.Sockets; namespace Shadowsocks.Util.Sockets { public static class SocketUtil { private class DnsEndPoint2 : DnsEndPoint { public DnsEndPoint2(string host, int port) : base(host, port) { } public DnsEndPoint2(string host, int port, AddressFamily addressFamily) : base(host, port, addressFamily) { } public override string ToString() { return this.Host + ":" + this.Port; } } public static EndPoint GetEndPoint(string host, int port) { IPAddress ipAddress; bool parsed = IPAddress.TryParse(host, out ipAddress); if (parsed) { return new IPEndPoint(ipAddress, port); } // maybe is a domain name return new DnsEndPoint2(host, port); } public static void FullClose(this System.Net.Sockets.Socket s) { try { s.Shutdown(SocketShutdown.Both); } catch (Exception) { } try { s.Disconnect(false); } catch (Exception) { } try { s.Close(); } catch (Exception) { } } } }