Results 1 to 1 of 1
  1. #1
    giersz2 is offline Member
    Join Date
    Apr 2012
    Rep Power

    Default Client blocks at reading from stream

    I will show only some important fragments of program


    Java Code:
    Some code in client:

    Java Code:
    msgType = clientApp.reader.readInt();
    switch (msgType){
    case 1: ... break;
    case 2: 
    clientApp.gamePanel.players = (ArrayList<Player>)clientApp.reader.readObject();
    //stops here
    clientApp.gamePanel.myId = clientApp.reader.readInt();
    The problem is that when client reads ArrayList<Player> object from stream, it blocks at readInt() method, despite server sent int after sending object. Then finally it passes readInt() after sending some data to server which is in some method called when some event occurs.

    ok, I think problem is solved. I put client.out.flush(); after writing last int and it works properly. I don't understand what does it change because I didn't use this method before while writing to the stream and everythink worked fine.
    Last edited by giersz2; 04-09-2012 at 07:48 PM.

Similar Threads

  1. Client/ Server system that adds a stream of integers
    By Billywizz in forum New To Java
    Replies: 12
    Last Post: 01-27-2011, 02:28 PM
  2. Trouble with Try Catch blocks and file reading.
    By theBurgh22 in forum New To Java
    Replies: 2
    Last Post: 11-30-2010, 02:11 AM
  3. TCP/IP Client program halts at the read method of the stream
    By PradeepBadiger in forum Networking
    Replies: 0
    Last Post: 03-26-2009, 04:14 PM
  4. Reading Client Windows Registry through browser
    By nareshnettem in forum Advanced Java
    Replies: 2
    Last Post: 05-14-2008, 07:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts