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 / General / August 2006

Tip: Looking for answers? Try searching our database.

EOFException after closing a socket

Thread view: 
Stefan Weber - 19 Aug 2006 00:54 GMT
Hi

I do something like that on one network node (site1):

socket = new Socket(...);
oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject(new Object());
socket.close();

On another node (lets call it site2) I frequently call

ois.readObject();

where ois is the ObjectInputStream on the same connection. I have set a
timeout for the socket at site 2. The idea is that I can do some other
work until the object actually arrived.

But unfortunately, this seems to raise problems when the socket on site
1 is closed before the object is read on site 2. In such cases, an
EOFException is thrown.
I'm not a 100% sure if this is really the reason, because it hardly
makes sense to me, because even though site1 closed the connection, the
data was sent to site2 and thus is available in the buffer...
Or does the exception arise due to another reason?

Thanks a lot! Regards,

Stefan Weber
Soren Kuula - 19 Aug 2006 01:19 GMT
> Hi
>
[quoted text clipped - 4 lines]
> oos.writeObject(new Object());
> socket.close();

Close oos instead ... that will flush thee stuff you are missing down
the Socket, before _that_ is closed (afterwards, automatically-cascaded,
as far as I remember).

Soren
vvk - 25 Aug 2006 08:29 GMT
hi,
when u close the socket, all the streams created with that socket are
closed. so when u attempt to read the streams from another node it will
araise the EOFException denotes that the socket is closed and cant
access the socket.
__Vasantha kumar
> Hi
>
[quoted text clipped - 24 lines]
>
> Stefan Weber


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



©2009 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.