Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URLConnection class. What for???  RSS feed

 
Murat Balkan
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is the purpose of URLConnection?
I can open a socket to a URL and for exp. send a POST request and close the connection.
I do not understand this class. Please help.
Thanks
Murat
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sending to the Socket and Internet Protocols forum.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can do all that by hand, but it would require your knowing the details of the HTTP protocol (and perhaps HTTPS, FTP, and other Internet protocols.) Potentially, this could include all sorts of complexities: dealing with proxies, SSL, partial transmissions, error handling, etc. You might need to sit down and study all these things so that you could implement them in your application. Good programming practice would, of course, dictate that you encapsulate all this HTTP/HTTPS/FTP protocol knowledge in its own class, so that other programmers could reuse that knowledge without learning all the details themselves.
Or, you could just use URLConnection, because somebody's already done all the work for you.
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Murat Balkan:
Hi,
What is the purpose of URLConnection?
I can open a socket to a URL and for exp. send a POST request and close the connection.
I do not understand this class. Please help.
Thanks
Murat

This is kind of like:
What is the purpose of calculators?
I can add 2 numbers in my head.
I do not understand this device. Please help.
If you're just gonna do simple stuff, then yeah, you don't need it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!