Click here to Skip to main content
15,888,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi basically i have create a console server that performs http responses. now the problem is that when ever it gets to read the packet data line by line it never ends and the browser page that i requested from stays in loading too and says waiting for server response,

here is the piece of code that i have in my server which reads packet data:

Java
try{
               dOut = new DataOutputStream(socket.getOutputStream());
           }catch(Exception ie){
               System.out.println("Cound'nt create dOut");
           }

           try{
               IR = new InputStreamReader(socket.getInputStream());
           }catch(Exception ie){
               System.out.println("Cound'nt create IR");
           }


           BufferedReader BR = new BufferedReader(IR);
           System.out.println("Received Request!");
           String MESSAGE = null;
           Stream<String> ReadPacket = null;

           try{
               ReadPacket = BR.lines();
           }catch(Exception ie){
               System.out.println("Couldn't Receive Message");
           }
           Object[] arr = ReadPacket.toArray();
           System.out.println(arr[0]+ " " + arr[1]+" " +arr[2]+" " +arr[3]+" " +arr[4]+" " +arr[5]+" " + arr[6]+" " +arr[7]);
           MESSAGE = arr[0].toString();


as you can see at the end of my code i have made it to print out the packet data being received, but it never gets to execute that line until i close the browser tab i request from,

What I have tried:

i also tried to use
Java
String reading = null, fullData = null;
while((reading = BR.readline()) != null){
fullData = fullData + reading;
}
here too the code never gets to execute println, i would really appreciate if you could tell what am i doing wrong.
Posted
Comments
Mr.willson 11-Aug-16 14:01pm    
hey can somebody reply to my question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900