Salve a tutti,qualcuno sa convertirmi questa parte di codice da poter utilizzare con httputils2?
Dim tcpClient As New System.Net.Sockets.TcpClient()
Dim port As Integer
Try
port = Convert.ToInt32(portTextBox.Text)
tcpClient.Connect(addressTextBox.Text.ToString(), port)
If tcpClient.Connected Then
Dim netStream As NetworkStream = tcpClient.GetStream()
If netStream.CanWrite And netStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("GET /state.xml?relay1State=" & val & " HTTP/1.1" & vbCrLf & "Authorization: Basic bm9uZTp3ZWJyZWxheQ==" & vbCrLf & vbCrLf)
netStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
netStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
End If
tcpClient.Close()
End If
Catch e As Exception
inputState.Text = "Error"
relayState.Text = "Error"
End Try
Dim tcpClient As New System.Net.Sockets.TcpClient()
Dim port As Integer
Try
port = Convert.ToInt32(portTextBox.Text)
tcpClient.Connect(addressTextBox.Text.ToString(), port)
If tcpClient.Connected Then
Dim netStream As NetworkStream = tcpClient.GetStream()
If netStream.CanWrite And netStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("GET /state.xml?relay1State=" & val & " HTTP/1.1" & vbCrLf & "Authorization: Basic bm9uZTp3ZWJyZWxheQ==" & vbCrLf & vbCrLf)
netStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
netStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
End If
tcpClient.Close()
End If
Catch e As Exception
inputState.Text = "Error"
relayState.Text = "Error"
End Try
Last edited: