Can I get access to the socket instance used by a URLConnection? I want to close the socket by force when the connected server doesn't answer.

John Zukowski

The answer to the first part is no. The type of connection used to get the content is hidden. In addition, a URLConnection does not necessarily get its content through a socket. Even the ContentHandler which gets the actual content doesn't have access to the socket.

On the other hand, if your connection is an HttpURLConnection, you can just call the disconnect() method.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact