0

It only happens in Androids, not PCs and my server is made using C++

Lets say I made a function for sending packet consists of 3 int and one char

void SendTestPacket(int num1, int num2, int num3) {
    System.out.println("Function called");
    if(true) {
        clientOut.writeInt(1); // clientOut is a DataOutputStream
        clientOut.writeInt(2);
        clientOut.writeInt(3);
        clientOut.writeChar('\n');
        System.out.println("Data sent");
    }
    System.out.println("Function fully executed");
}

I tried using my android client to send one packet on every finger pan function called which has been called more than 1000~2000 times in 5 secs when dragging finger around the screen.

Somehow, during the process of dragging my finger, the function stop executing properly especially starting from the first clientOut.writeInt(int); until the end of if section. It's like 'break'or 'continue' statement has been called.

In the early part, I always got these kind of output

Function called
Data sent
Function fully executed

After a few moment, it became these kind of output every loop

Function called
Function fully executed

If I tested it on pc java client, it will never occurs no matter how I do it Sorry I forgot to mention it, its on Wirelesss Lan connection.

Edit

Actual Function Code

void SendTestPacket(int packettype, int num1, int num2) {
    System.out.println("Function called");
    try {
        clientOut.writeInt(packettype); // clientOut is a DataOutputStream
        clientOut.writeInt(num1);
        clientOut.writeInt(num2);
        clientOut.writeChar('\n');
        System.out.println("Data sent");
    } catch (IOException e) {
        e.printStackTrace();
    }
    System.out.println("Function fully executed");
}
D13
  • 123
  • 3
  • 12
  • I think the most likely result is that the real if statement (if (true) is obviously example code) is false so it skips the write. That's far more likely than 2 basic classes breaking without throwing exceptions. – Gabe Sechan Mar 12 '15 at 18:29
  • Not really, the reason I put the 'if' statement because I wanna write is as an example where it can show you it happens on what level because this bug really skips in a logic section level. The bug still occurs when I write the function even without the 'if' statement. – D13 Mar 12 '15 at 18:34
  • In actual codes, I already added the catch IOException code but no error came out which really push me to the limit. I've been working on fixing this bug for 4 hours straight which is good enough for me to point out that the bug actually came from the DataOutputStream write function. The C++ server connection still open and still waiting for new packets. So where else to check when there's really no problem with the server code when it works perfectly with pc java client.. – D13 Mar 12 '15 at 18:40
  • I suggest you did get an IOException and you missed it. – user207421 Mar 12 '15 at 21:53
  • Nah.. Instead of missed it, its more like it just won't print any stacktrace. And I tried using OutputStream directly for sending data just now, the same stuff happens.. So now OutputStream became the main suspect. :( Still checking out the actual cause. – D13 Mar 12 '15 at 22:26
  • I think I know the cause now after I checking this link related with OutputStream title related. http://stackoverflow.com/questions/1338885/java-socket-output-stream-writes-do-they-block – D13 Mar 12 '15 at 22:35

0 Answers0