I have Java client application that is connecting with server via sockets. The app creates two streamed classes - reader and writer - for incoming and outcoming messages. I run my client on S40 6th Edition SDK and S40 5th Edition SDK emulators, the server sends several messages but the client either receives only 1 message and ignores the rest, or receives several messages, and then the emulator writes:

Warning: Traffic View: Listing of TCP/UDP Received traffic is set to off

and my reader class throws IOException.

What could be the reasons - do I incorrectly something?


 public void run() {
 try {
     in = connection.openDataInputStream();
     while (!stopped) {
         byte[] cmdLength = new byte[4];
         int length = /* cmdLength transfer to int */
         byte[] cmd = new byte[length];
         in.readFully(cmd, cmdLength.length, length);
 } catch (IOException e){

at com.sun.midp.io.j2me.socket.Protocol.nonBufferedRead(+142)
 at com.sun.midp.io.BufferedConnectionAdapter.readBytes(+39)
 at com.sun.midp.io.BaseInputStream.read(+44)
 at java.io.DataInputStream.read(DataInputStream.java:149)
 at java.io.DataInputStream.readFully(+34)
 at java.io.DataInputStream.readFully(DataInputStream.java:169)
 at ru.kalyukin.ubiqmobile.client.ClientReader.readCommandLength(ClientReader.java:102)
 at ru.kalyukin.ubiqmobile.client.ClientReader.run(ClientReader.java:57)
Thank you,