Java Network Programming by Elliotte Rusty Harold

Java Network Programming by Elliotte Rusty Harold

Author:Elliotte Rusty Harold
Language: eng
Format: epub, mobi, pdf
Tags: COMPUTERS / Programming Languages / Java
ISBN: 9781449357665
Publisher: O’Reilly Media
Published: 2013-10-03T16:00:00+00:00


Disconnecting from the Server

HTTP 1.1 supports persistent connections that allow multiple requests and responses to be sent over a single TCP socket. However, when Keep-Alive is used, the server won’t immediately close a connection simply because it has sent the last byte of data to the client. The client may, after all, send another request. Servers will time out and close the connection in as little as 5 seconds of inactivity. However, it’s still preferred for the client to close the connection as soon as it knows it’s done.

The HttpURLConnection class transparently supports HTTP Keep-Alive unless you explicitly turn it off. That is, it will reuse sockets if you connect to the same server again before the server has closed the connection. Once you know you’re done talking to a particular host, the disconnect() method enables a client to break the connection:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.