Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

socket acting like "canal"-one side flow only??

 
basha khan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have one socket.
my socket is having one inputstream(in) and one outputstream(out).
suppose my inputstream is waiting like
in.readline() //waits here ..not getting the data ... waits
then
if i am trying to put some value to my outputstream .. like
out.write("somevalue");
what will happen to the "somevalue" in my outputstream?.is the value sent??.(consider my inputstream.it's still waits for data).
i tried..data not sending.socket connection is acting like a one channel canal.
but i want to sent my data when inputstream waits(unavoidable).what to do??.anyone knowing?
welcome to all logics & tricks.
basha
SCJP
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting your reader on its own thread. Here's a snippet from a client that sends commands to a server and may get zero or many responses over a period of time. This code is in a little class that just pulls lines out of the socket:

The rest of the client can continue to run without waiting for the reader.
[ April 02, 2003: Message edited by: Stan James ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic