• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

only one side??

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it sounds like you are using the old style "blocking" IO streams. Are you using two separate threads for read/write ops? if not, then your program will "block" at the read method until it receives input - the rest of your program will not execute.
to avoid this, look in to the java.nio package (java 1.4 and above). it has the capabilities for non-blocking IO. There are some great tutorials out there - i've listed a couple links below, do a google search for more. nio takes some getting used to, but it is very worthwhile to learn.

http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html
http://www.owlmountain.com/tutorials/NonBlockingIo.htm
 
basha khan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi jon,

it sounds like you are using the old style "blocking" IO streams. Are you using two separate threads for read/write ops?


Defenitely i m using old style.I m not aware of nio package yet.
thank u jon
basha
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic