Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This doesn't directly answer your question, but it is (IMO) worth saying anyway ... </p> <p>If your homework assignment doesn't <strong>specifically tell</strong> you to use a socket directly, there are simpler, and better ways of doing HTTP file upload and download in Java:</p> <ul> <li><p>Using <a href="http://download.oracle.com/javase/6/docs/api/java/net/URL.html#openConnection%28%29" rel="nofollow"><code>java.net.URL.openConnection()</code></a> on an "http:" url will give you an <a href="http://download.oracle.com/javase/6/docs/api/java/net/HttpURLConnection.html" rel="nofollow"><code>HttpURLConnection</code></a> that you can use to make GET, PUT, POST and so on requests to the remote server. This takes care of the basic HTTP protocol stuff for you.</p></li> <li><p>The <a href="http://hc.apache.org/httpcomponents-client-ga/index.html" rel="nofollow">Apache HttpClient</a> libraries do the same thing, but in a more sophisticated way, with more options and more hooks for things like handling content (including forms and MIME multiparts), connection and credential management, proxying and route finding and so on.</p></li> </ul> <p>If the aim of your homework exercise is to teach you practical ways to talk to remote servers, then using these classes is far more practical than trying to implement a subset of the HTTP protocol from the socket level up.</p> <p>(Of course, the aim <em>could</em> be to give you a deeper understanding of the HTTP protocol at the "wire" level ... which would make your current approach the right one.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload