Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 11336

HTTP rede local

$
0
0
Boas pessoal Estou a tentar ler o codigo fonte de paginas http o qual tenho este código que funciona perfeitamente para servidores remotos: Public Shared Async Function GetServerResponse(iRemoteServer As String) As Task(Of String) ' Try 'Create an HTTP client object Dim vHTTPClient As New Windows.Web.Http.HttpClient() ' 'Add a user-agent header to the GET request. Dim vHeaders = vHTTPClient.DefaultRequestHeaders ' 'The safe way to add a header value is to use the TryParseAdd method and verify the return value is true, 'especially if the header value is coming from user input. Dim vHeader As String = "ie" If Not vHeaders.UserAgent.TryParseAdd(vHeader) Then Exit Try 'Invalid header value: " & vHeader vHeader = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)" If Not vHeaders.UserAgent.TryParseAdd(vHeader) Then Exit Try 'Invalid header value: " & vHeader Dim vRequestUri As New Uri(iRemoteServer) 'Send the GET request asynchronously and retrieve the response as a string. Dim vHTTPResponse As New HttpResponseMessage() Dim vHTTPResponseBody As String = "" Try 'Send the GET request vHTTPResponse = vHTTPClient.GetAsync(vRequestUri) vHTTPResponse.EnsureSuccessStatusCode() vHTTPResponseBody = Await vHTTPResponse.Content.ReadAsStringAsync() Catch ex As Exception Return Nothing End Try ' Return vHTTPResponseBody ' Catch ex As Exception ' End Try ' Return Nothing End Function acesso como: Dim vResponse = WebRequests.GetServerResponse("http://www.google.pt/") No entanto tenho um arduino conetado em rede e envia respostas em http. Dim vResponse = WebRequests.GetServerResponse("http://192.168.1.70/") quando tento aceder ao arduino para obter a resposta http o codigo acima falha. Alguem me pode dar uma ajuda nisto? Obrigado

Viewing all articles
Browse latest Browse all 11336

Trending Articles