public static async Task <IHttpSocketAdapter> OpenHttpSocketAsync(string httpMethod, Uri url) { ISocketAdapter socket = await SocketAdapter.OpenSocketAsync(url); if (socket != null) { return(new HttpSocketAdapter(httpMethod, url, socket)); } return(null); }
internal static async Task <ISocketAdapter> OpenSocketAsync(Uri url) { try { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); SocketAdapter adapter = new SocketAdapter(socket); await adapter.ConnectAsync(url); return(adapter); } catch { // Handle any socket error and return null } return(null); }