Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object streams and readers

Nirmal Mekala Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I have objectinputstream and a bufferedreader both open on a single socket connection, between same client and server at the same time.

client = new Socket(ip,4444);
out= new PrintWriter(client.getOutputStream(),true);
in= new BufferedReader(new InputStreamReader(client.getInputStream()));
ObjectInputStream ois = new ObjectInputStream(client.getInputStream());

I tried this but i'm getting the following exception
{ invalid stream header
at com.SearchClient$

If i cannot have both a stream and a reader open on same socket, could anyone please suggest how i pass different kind of data between my server and client. The situation is : I want normal string based communication for requests and acknowledgements (like "open", "ok","process","ok" etc) and also able to send an object(array) over the stream.
Please help me out.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic