File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes socket acting like Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "socket acting like "canal"-one side flow only??" Watch "socket acting like "canal"-one side flow only??" New topic
Author

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

basha khan
Ranch Hand

Joined: Jan 18, 2002
Posts: 87
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

Joined: Jan 29, 2003
Posts: 8791
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 ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: socket acting like "canal"-one side flow only??
 
Similar Threads
Socket reply problem
only one side??
JUnit and Sockets
Networking performance questions
Java: Convert a binary file to "text" and back again.