Question

Client/ server socket... optionalDataException randomly...

Asked by: Thunder_scream

Hi!


Below is my entire..code...just feel that it would be better to link the rather than paste it here.....


http://www.geocities.com/shomnv97/Client.java
http://www.geocities.com/shomnv97/Server.java
http://www.geocities.com/shomnv97/serializedObj.java

I'm using ObjectInpu/ouputStream and would like to keep it so if possible....and I have j2sdk1.4.2_03 running winxp and fedora that is tried it on both os.

ok the Problem:

I'm a bit confused, because if I debug my apps with jbuilder 9 everything works as it should but when the application runs
and I send a file to the server from the client....it randomly gives me optionalDataException or something related with Serialization or ObjectStream exception
I know where the error is but can not do anything about it.....or i think I know...:))

the input stream reads one inputstream twice...for some unknown reson...??
that is it reads the same incomming object twice...I have tried reset() ...both
before my output.WriteObject, output.flush and After.....and both ..before and after :)) with no ...success..

anyway..the error is somewhere in here....
in the server.java
prepareToReciveFile();

..or  in client.java
 sendInputFile();


The app works fine or gives me less exceptions if there is some delay..
e.g...if I have my client running on another machine somewhere..

If you decide to help me ....remove the "package networking" reference in the begining of each java file :)

To summarize...this app establishes a socket connection between client and a server and .....sends a file..to the server...the server produces a ouput file...
and saves it both in its working directory and sends a copy to the client...(its in this process that I get my error.)
The entire idea is to be able to send a computational problem to the server...adn the server..divides the task between its conected clients and send back the result..to the initial client......or simply send any file...to the server...this is some extra information...really...

Would appriciate if anyone could help me out correcting this ..bugg...and comments on code would be welcomed.
Thanks

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-03-15 at 22:40:54ID20920159
Tags

optionaldataexception

Topic

Java Programming Language

Participating Experts
2
Points
0
Comments
19

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. String to InputStream
    hi, I have a prepared String which I want to bring into an InputStream for functions to do things with - how ? Regards, GOMF
  2. Socket Exception InputStreams?
    Hi, I'm making a simple proxy program. Reading in on one InputStream (from) and writing to an OutputStream (to). Here's the code: try { // read the stuff in from the port int data; while ((data = from.read()) != -1) { System.out.println("Read somethi...
  3. Problem with SAXParser's InputStream
    Hi, I'm having a problem getting the SAXParser to work the way I need it. It appears that when parsing an InputStream rather than a file, the socket that's providing the InputStream has to close/disconnect before the SAXParser recognizes this as the end of the write. Th...
  4. TimeOut in Inputstream
    Hi, I am looking for an efficient implementation of InputStream whit timeout, like in sockets The constructor of this Inputstream should get a timeout parameter The read method should throw IOException if waiting on read exceeds this timeout.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Thunder_screamPosted on 2004-03-15 at 23:22:31ID: 10604034

sorry about the low points but do not have much left....but I need help...

 

by: Thunder_screamPosted on 2004-03-15 at 23:25:10ID: 10604047

just increasing points:))

 

by: CEHJPosted on 2004-03-16 at 04:58:37ID: 10605649

You haven't helped yourself by leaving your catch blocks empty in those two methods. In Server.java, change

>>
    catch (IOException ex) {
    }
>>

to

catch (Exception ex) {
      System.err.println("Error in Server.prepareToReciveFile():");
      ex.printStackTrace();      
}

and do the equivalent in the Client method


 

by: CEHJPosted on 2004-03-16 at 04:59:56ID: 10605655

When doing the above, you can delete

>>
    catch (ClassNotFoundException ex) {
    }
>>

in the Client method

 

by: Thunder_screamPosted on 2004-03-16 at 05:56:24ID: 10606084

I the code was nice and neat until I ran into....this problem...then I started to add and take away stuff just to test...
that's mainly why the catch methods are left empty....

Can anyone tell me where the error is comming from and how I can fix it.

 

by: CEHJPosted on 2004-03-16 at 06:44:57ID: 10606531

Put the catch blocks back as i specified. Retest it. Report again. Then we can talk..

 

by: Thunder_screamPosted on 2004-03-16 at 09:28:52ID: 10608003

ok the code is updated catch blocks

and here are erros....

//////////////////////////////////////////////////////////////////
error in server fileCtrlAllows()
java.io.EOFException
      at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2435)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1245)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      at networking.Server.fileCtrlAllows(Server.java:244)
      at networking.Server.prepareToReciveFile(Server.java:199)
      at networking.Server.processConnection(Server.java:165)
      at networking.Server.runServer(Server.java:97)
      at networking.Server$ServerThread.run(Server.java:624)

error in server processConnection()
java.io.EOFException
      at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2435)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1245)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      at networking.Server.processConnection(Server.java:162)
      at networking.Server.runServer(Server.java:97)
      at networking.Server$ServerThread.run(Server.java:624)
null

error in server processConnection()
java.io.EOFException
      at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2435)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1245)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      at networking.Server.processConnection(Server.java:162)
      at networking.Server.runServer(Server.java:97)
      at networking.Server$ServerThread.run(Server.java:624)
null
/////this error looopss for ever

///////////////////////////////////////////////


////////////////////////////////////error on Client side...
Error in Client.initFileTrans();
java.io.OptionalDataException
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1285)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      at networking.Client.initFileTrans(Client.java:547)
      at networking.Client.sendInputFile(Client.java:647)
      at networking.Client.processConnection(Client.java:275)
      at networking.Client.runClient(Client.java:209)
      at networking.Client.access$300(Client.java:25)
      at networking.Client$ServerThread.run(Client.java:531)

Error in Client.runClient();
java.io.OptionalDataException
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1231)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      at networking.Client.processConnection(Client.java:271)
      at networking.Client.runClient(Client.java:209)
      at networking.Client.access$300(Client.java:25)
      at networking.Client$ServerThread.run(Client.java:531)
false overwirte2

///////////////////////////////////////////

 

by: Thunder_screamPosted on 2004-03-16 at 19:05:39ID: 10612172

any suggestion on what to do .??

 

by: CEHJPosted on 2004-03-19 at 02:28:43ID: 10631894

I've been away from a short while. Any progress in the meantime?

 

by: Thunder_screamPosted on 2004-03-19 at 09:03:37ID: 10634620

well no....I've solved it by not using..... the objectInput/OutputStream... which I really didnt want to do....
thanks anyway

 

by: CEHJPosted on 2004-03-19 at 09:08:50ID: 10634670

You mean you didn't want to ditch OIS/OOS? You should not have been calling reset

 

by: Thunder_screamPosted on 2004-03-19 at 10:45:32ID: 10635597

Hi! CEHJ

Yes... exactly ...I did not want to ditch OIS/OOS but...there seemed to be no solution to the problem..
I have tried with and without..reset..as stated abit unclear earlier
...however..It did not make anything better or worse..for me...



 

by: CEHJPosted on 2004-03-19 at 11:21:16ID: 10635937

Well we could still have a go. Post your latest versions up there on geocities. Make sure they compile

 

by: Thunder_screamPosted on 2004-03-19 at 14:34:39ID: 10637553

ok...I've removed the package names ...and posted the latest version I had with  OIS/OOS up until I changed tactics  :))
and by the way there are no resets in this...one.

how you can reproduce the error..:
if you add some files...to the client and send it to the server for more detail you can read the Readme.txt file...here

http://www.geocities.com/shomnv97/CSReadMe.txt

once you have done that...try to send to server...might work fine...but try again...by just clicking send again.
..and around the 3rd time..you'll get the below error...due to that everything gets unsync somehow


//On client side
Error in Client.sendInputFile();
java.io.EOFException
        at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputSt
ream.java:2435)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1245)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
        at Client.sendInputFile(Client.java:655)
        at Client.processConnection(Client.java:272)
        at Client.runClient(Client.java:206)
        at Client.access$300(Client.java:22)
        at Client$ServerThread.run(Client.java:527)
Server terminated connection


//The last errors produced... on server side..
java.lang.ClassCastException
        at Server.processConnection(Server.java:168)
        at Server.runServer(Server.java:103)
        at Server$ServerThread.run(Server.java:648)

 

by: CEHJPosted on 2004-03-19 at 16:22:27ID: 10638096

Couldn't reproduce it actually. Sent two or three files - no errors

 

by: Thunder_screamPosted on 2004-03-19 at 17:51:45ID: 10638466

what verison of skd are you runing and what's your platform...
I have tried this on linux,unix,Mac and winxp...same kind of error...

 

by: Thunder_screamPosted on 2004-03-19 at 18:04:05ID: 10638531

However..I'd like to thank you for ..your effort to help me...but I feel...that since
you can not produce the same error.and there is no one else responding to this
question...its time to close this question. Additionally I have found my own solution
simply using more primitve streams..stated earlier...

 

by: PashaModPosted on 2004-03-25 at 07:00:38ID: 10677568

Closed, 115 points refunded.
PashaMod
Community Support Moderator

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...