![]() |
|
|
|||||||
![]() |
Java - java.net.Socket.close() and getInputStream |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi,
after obtaining an InputStream from a Socket, do I have to close it seperately or does it suffice to close the Socket itself? Thanks, Harald. HK |
|
|
|
|
#2 |
|
Posts: n/a
|
On 10 Mar 2005 08:19:01 -0800, HK wrote:
> after obtaining an InputStream from a Socket, do I have to close it > seperately or does it suffice to close the Socket itself? You should close the InputStream. It will close the Socket for you. If you wrap the InputStream in another stream type, close that instead. In other words, always close the *outermost* stream. /gordon -- [ do not email me copies of your followups ] g o r d o n + n e w s @ b a l d e r 1 3 . s e Gordon Beaton |
|
|
|
#3 |
|
Posts: n/a
|
Gordon Beaton wrote:
>On 10 Mar 2005 08:19:01 -0800, HK wrote: > > >>after obtaining an InputStream from a Socket, do I have to close it >>seperately or does it suffice to close the Socket itself? >> >> > >You should close the InputStream. It will close the Socket for you. > > > Is it possible to close a Socket's InputStream but not close the Socket, and then use its OutputStream for example? Martin A |
|
|
|
#4 |
|
Posts: n/a
|
On Fri, 11 Mar 2005 10:04:46 +0100, Martin A wrote:
> Is it possible to close a Socket's InputStream but not close the > Socket, and then use its OutputStream for example? Socket.shutdownInput() in that case. /gordon -- [ do not email me copies of your followups ] g o r d o n + n e w s @ b a l d e r 1 3 . s e Gordon Beaton |
|