Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2004

Tip: Looking for answers? Try searching our database.

A socket is closed without closing it explicitly

Thread view: 
Lior - 30 Aug 2004 14:36 GMT
Hi all,

Could someone explain to me the following phenomenon:
I opened a socket and sent data successfully with the following lines:
BufferedWriter wr = new BufferedWriter(new
OutputStreamWriter(m_socket.getOutputStream()));
wr.write(m_data);
When I want to receive a response with the following line:
BufferedReader rd = new BufferedReader(new
InputStreamReader(m_socket.getInputStream()));
I get an exception that the socket is closed, even though I didn't
close it explicitly.
Did I miss something?
Please help.

Thanks, Lior
Stefan Schulz - 30 Aug 2004 14:49 GMT
> Hi all,
>
[quoted text clipped - 8 lines]
> I get an exception that the socket is closed, even though I didn't
> close it explicitly.

Did the remote side close the Socket? Sorry, but this is the simplest
answer that comes to mind ;)

See you
Stefan
Gordon Beaton - 30 Aug 2004 15:03 GMT
> Could someone explain to me the following phenomenon:
> I opened a socket and sent data successfully with the following lines:
[quoted text clipped - 9 lines]
>
> Did I miss something?

My guess is that you closed the BufferedOutputStream. Doing so will
close the OutputStreamWriter and the underlying Socket.

/gordon

Signature

[  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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.