convert to xojo from java?

[code]public static void shutdown() {
try {
String protocol = “http” + (ssl?“s”:"");
URL url = new URL( protocol, “127.0.0.1”, port, “command”);
HttpURLConnection conn = getConnection( url );
conn.setRequestMethod(“GET”);
conn.setRequestProperty(“servicemanager”, “command”);
conn.connect();

        StringBuffer sb = new StringBuffer();
        BufferedReader br = new BufferedReader( new InputStreamReader(conn.getInputStream(), "UTF-8") );
        int n; char[] cbuf = new char[1024];
        while ((n=br.read(cbuf, 0, cbuf.length)) != -1) sb.append(cbuf,0,n);
        br.close();
        System.out.println( sb.toString().replace("<br>","\

") );
}
catch (Exception ex) { }
}[/code]

Anyone able to help me port this to RB?

Off the top of my head, something along the lines of:

Dim socket1 As New HTTPSocket
Dim data As String

socket1.port = <the port number>
data = socket1.Get(yourURL + servericemanagerstring + commandstring, 30)

if data <> "" then
   data  = data.defineencoding(encodings.utf8)
   ... Parse through the data ...
   data = replaceall(data, "<br>", endofline)
end if

Note that this is just a quick thought and I have not tested it. I’m currently sitting in my car waiting for my daughter. You can probably skip the port number and built that directly into “yourURL”. You will also need to build in error checks and stuff, but I think this should get your going. For HTTS, there is also the HTTPSecureSocket.

Sorry for all the typos, not easy typing on iPhone with big fingers.

That’s almost right. You’re going to want to use an HTTPSecureSocket instead if you want to be able to switch on the fly.

Learned something new today. Thanks Greg :wink:

mucho gracias, merci, danke, cam-on lam!
oh… and thanks!

I’m not sure what the command, conn.setRequestProperty(“servicemanager”, “command”); does.
but this concatination doesn’t seem to be formatted properly…

socket1.Get(yourURL + servericemanagerstring + commandstring, 30)

[quote=33426:@Brian O’Brien]mucho gracias, merci, danke, cam-on lam!
oh… and thanks![/quote]

It’s not often you see Vietnamese around here - are you a native speaker?

no… just been around the world a few times… more like in orbit…

Everything in between the “(” and “)” is the string you need to construct to get to where you need to go. You will need to figure out from your original code what “servicemanager” is and “command” is.

yourURL + servericemanagerstring + commandstring
  ** I added "string" to the end to show you that they the properties (servicemanager, command) you need to set are strings

That is basically joining the URL with whatever you are trying to get at. When it is all set and done, your connection/URL string should look something like:

http://www.yourdestinationsite.com/service.html?command=a_command&additional_property_a=whatever&addtional_property_b=whatevertoo

More or less…