Question Help Sending commands via WebClient

KenGo

New member
Joined
Dec 10, 2010
Messages
3
Programming Experience
Beginner
I'm currently using VB (2010 Express) to send commands to an AMX controller.
Although it is working... some what. I'm not sure if I'm doing it the correct way or if there is a better way.

The AMX controller is listening on port 8888 for a "REQUEST" with a number after it. From a browser I can type "http://192.168.1.32:8888/REQUEST1" and the AMX controller handles request 1. And the browser displays a message "Function 1 received" (generated by the AMX controller code).

Although at this time I don't care what the webpage says, I'm using DownloadString() to send the request that executes the command. In doing so the controller is getting the "request" but I'm getting an exception. Is there a better way to do this so it will only through an exception if the ip address is invalid?

Code:
Dim RetrivedIP As String = "192.168.2.32"
Dim Command As String = ("http://" & RetrivedIP & ":8888/REQUEST1")
Try
Dim client As WebClient = New WebClient
Dim reply As String = client.DownloadString(Command)
textbox1.text = ("Never makes it here")
Catch ex As Exception
'DO NOTHING
textbox1.text = ("Exception")
End Try


Thanks for the help in advance.

Ken
 
I'm getting an exception.
That is rather significant for debugging. What exception and message are you getting?
 
Please forgive me because I'm not sure how to answer that question. When I take the Try out I get a message saying
"WebException was unhandled"
"The server committed a protocol violation. Section=ResponseStatusLine"
If there is another way I should be looking for the exception or error that will help please let me know

Thanks.
 
Thank you for that information, but I don't know how that helps me.

Is DownloadString() the correct way to be sending this command?

What is the correct way to view the exception?

Thanks,

Ken
 
DownloadString should be a valid approach, but the server you're requesting seems to not give appropriate response, thus the work-arounds suggested.
Fiddler is something I also highly recommend for debugging what is going on, especially since you have successful requests from your browser client.
 
Back
Top