🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #682

Re: Closing Sockets

#682
From: lans
Date: Fri, 18 Feb 2005 22:03
26 lines
2002 bytes
Shankar Unni <shankarunni@netscape.net> wrote:
>lans wrote:
>
>> out.close()
>> in.close()
>> socket.close()
>
>A little bit more information, please?
>
>What are "out" and "in"? Are they connected to the socket? If so, how 
>does your logic do the connection? Every time you open the socket, do 
>you immediately connect "out" and "in" to the socket? If so, you're OK, 
>since you'll get a brand new out and in.
>
>But it's generally good etiquette to close any streams that you open. 
>Also, for sockets, it's polite to shut down the socket cleanly before 
>closing it.  (See Socket.shutdownInput() and Socket.shutdownOutput()).

in and out are IO classes( bufferedreader and print Writer which I use to get a handle to the inout and ooutput stream on the socket.

I then store the socket in a hashtable for later user.  If the server that I'm connected to losses connection then the socket will throw a Socket Exception.  

I then close the socket without closing the stream.  Based on the docs it says when you close a socket then any handle to the scoket is also closed and you have to create a new socket connection.

Is there any real problem not closing the io streams before closing the socket
Technical Details
Message-ID: <42166618$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4216486c$1@newsgroups.borland.com> <42165906$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,6bffc2bbc580287c
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "lans" <sirlanslot@aol.com>
Sender: "lans" <sirlanslot@aol.com>
Reply-To: "lans" <sirlanslot@aol.com>
Subject: Re: Closing Sockets
Newsgroups: borland.public.jbuilder.java.language
X-User-Info: 64.214.127.50     
References: <4216486c$1@newsgroups.borland.com> <42165906$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <42166618$1@newsgroups.borland.com>
Date: 18 Feb 2005 14:03:04 -0800
X-Trace: newsgroups.borland.com 1108764184 207.105.83.66 (18 Feb 2005 14:03:04 -0800)
Lines: 28
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail