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 / February 2006

Tip: Looking for answers? Try searching our database.

java socket question

Thread view: 
Shin - 06 Feb 2006 06:24 GMT
I am doing a customized object serialization  over socket, and I am
getting this "SocketException: Connection Reset" problem.  Hope someone
can give me a hint.

Here is what I did:
create a socket;
get both input/output stream from the socket;
create object input/output streams from them;

the client will write a few objects and then wait to read an object;
the server read these objects and do something and write an object;

On each side, I just do this after all code:

objInStream.close();
objOutStream.close();
socket.close();

So, what else I need to get rid of this "connection reset" thing?  Like
setting one of these keepALive, soLinger, or timeOut things on the
socket?

Thanks,
-b
EJP - 07 Feb 2006 05:00 GMT
> I am doing a customized object serialization  over socket, and I am
> getting this "SocketException: Connection Reset" problem.  Hope someone
[quoted text clipped - 13 lines]
> objOutStream.close();
> socket.close();

Two suggestions: (a) close the output stream before the input stream.
Actually you only need to close the output stream, the input close and
socket close are then redundant. (b) Don't close a socket until you have
read all the data from it, i.e. really until you have read EOF,
otherwise the writing end will get this reset condition.
Shin - 07 Feb 2006 19:52 GMT
Thanks,  EJP.

I ended up letting the reader send a confirmation back to the sender
and then close everything (this, in turn, will seem to cause the
problem of reader needing to wait for a confirmation on confirmation by
sender, but so far it seems fine).

I guess a better solution would be something you suggested, by closing
the stream/socket in *some* order and, thus, ensuring no "connection
reset".  I was getting the error at reader end; so the error must come
from sender closing output stream and socket.  Anyway, I couldn't find
a definitive protocol in such situation to use.

Maybe I will try yours next time.

-Shin
threadsafe - 10 Feb 2006 21:56 GMT
> I am doing a customized object serialization  over socket, and ...
Rather than coding your own client and server you may wish to try
components such as DualRpc (www.retrogui.com), RMI (sun.java.com) or
QuickServer (www.quickserver.org)

Regards,

Threadsafe


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.