After running the following Java code, I am getting very accurate and consistent results in determining whether I am testing I am .
Secure synchronized Boolean checkroom (HTRUR connection connection) {Boolean error = false; // HttpURL Connection Connection = Faucet; Gregorian calendars calendar = new Gregorian calendar (); Try {if (connection! = Null) {connection.connect (); // 200 expected HTTP_OK response error = processResponseCode (connection.getResponseCode ()); Connection.disconnect (); } And {error = false; }} Hold (java.net.UnknownHostException uhe) {...} hold (exception e) {...} return error; }
In C #, there is a lot of false positives (mostly because of termination - which is the default duration of 100000mm) in the closest match of the Java pattern.
Protected Bull Linked URL = false; Reaction = null; HttpWebRequest webreq = (HttpWebRequest) WebRequest.Create (this.getUri ()); Webreq.Credentials = Credential cache. Default credentials; WebResponse res = null; // webreq.GetResponse (); WebRequest request = WebRequest.Create (this.getUri ()) Try WebRequest; request. Credential = Credential Cache. Default credentials; If (request! = Null) {// Get feedback res = webreq.GetResponse (); ConnectedToUrl = processResponseCode (res); } Else {logger.Fatal (getFatalMessage ()); String error = string Empty; }} Hold (exception e) {throw e; } URL associated with return; }
I have tried various methods in C # to match the effectiveness of the Java code quoted, it has no advantage.
Any thoughts?
Just change it:
res = webreq.GetResponse () ; ConnectedToUrl = processResponseCode (res); By using
(WebResponse res = webreq.GetResponse ()) {connectedToUrl = processResponseCode (res); }
(Remove the announcement in advance.)
Unless you have stopped the response (or it has been finalized), it is holding onto the connection is. You can only have a certain number of connections (2 by default, I believe) with any one host at one time, so the timeout. When you resolve the response, it allows another request to use the same connection.
Comments
Post a Comment