In my project, I use the C # application client and the tomcat6 web application server. I wrote this snippet in a C # client:
public bool isServerOnline() { Boolean ret = false; try { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(VPMacro.MacroUploader.SERVER_URL); req.Method = "HEAD"; req.KeepAlive = false; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); if (resp.StatusCode == HttpStatusCode.OK) { // HTTP = 200 - Internet connection available, server online ret = true; } resp.Close(); return ret; } catch (WebException we) { // Exception - connection not available Log.e("InternetUtils - isServerOnline - " + we.Status); return false; } }
Every time I call this method, I get a new server-side session. I assume this because I have to use HTTP cookies in my client. But I do not know how to do this, can you help me?
source share