• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Transforming a non blocking InputStream to a blocking one

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem to getting a full response when i made a connection with a socket to a jboss service,because the jboss generates a message1 then after a while generates a message 2,the method readBuffer reads in run mode only the message1 and don't wait for the server to send the message2,but in the debug mode readBuffer reads both message1 and message2.

How can i make my method readBuffer waits for the jboss service to send both message1 and message2 in other words how can i transform the non blocking InputStream is in a blocking one ?


import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;


............

private Socket s;
private InputStream is;
private OutputStream os;


s = new Socket(host, port);

is = s.getInputStream();


//methode to read from the jboss service.
public readBuffer(byte[] buf)
{

try
{

int size = is.read(buf)
}

catch(Exception e)
{..

}



}


Thank you

Ismail

[ November 28, 2008: Message edited by: ismail hassani ]

[ November 28, 2008: Message edited by: ismail hassani ]

[ November 28, 2008: Message edited by: ismail hassani ]
[ November 28, 2008: Message edited by: ismail hassani ]
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you reading raw socket data? If yes, is there any protocol you are following?
How, do you determine when message1 is finished or infact any message has finished?
Can you provide us the existing readBuffer() code?

ismail the method readBuffer reads in run mode only the message1 and don't wait for the server to send the message2,but in the debug mode readBuffer reads both message1 and message2.


How does your client change between "run mode" and "debug mode"?

ismail how can i transform the non blocking InputStream is in a blocking one ?


Does it really matter over here whether it is blocking or non-blocking?
Your reader needs to determine that whether it has read message 1 & 2 both or not. How does it matter whether the read is blocking or non-blocking?

P.S.: Please UseCodeTags while posting code.
[ December 01, 2008: Message edited by: Nitesh Kant ]
 
Grow a forest with seedballs and this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic