Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }