Page 1 of 2 12 LastLast
Results 1 to 20 of 22
  1. #1
    jvb2008 is offline Member
    Join Date
    Mar 2017
    Posts
    9
    Rep Power
    0

    Default DataOutputStream max number of bytes written

    Hello,

    I need help with DataOutputStream, how many bytes can i write via socket in this type of Streams for java and Android app? When I write more than 720B I have problems.


    Thanks in advance,

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: DataOutputStream max number of bytes written

    When I write more than 720B I have problems.
    That looks like a lot of bytes: 720,000,000,000
    What is the destination being written to?
    What is the problem? Copy any error messages and paste them here.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jvb2008 is offline Member
    Join Date
    Mar 2017
    Posts
    9
    Rep Power
    0

    Default Re: DataOutputStream max number of bytes written

    Hi Norm,

    The source is a tablet and destination IP adressed PC. Communication is via socket like

    myClient = new Socket(IP, PORT);
    DataInputStream in1 = null;
    DataOutputStream out1 = null;
    out1 = new DataOutputStream(miCliente.getOutputStream());
    in1 = new DataInputStream(miCliente.getInputStream());
    send(out1);


    public void send(DataOutputStream out) {
    out.writeInt(swap4(60));
    for (int i = 0; i < 60; i++) {
    out.write(hexStringToByteArray("0100"); //2B
    out.write(hexStringToByteArray("54"), out); //1B
    out.write(hexStringToByteArray("1102180D0F"), out); //5B
    out.write(hexStringToByteArray("535D"), out); //2B
    out.write(hexStringToByteArray("5F1D"), out); //2B
    }


    In this case I am sending 12Bytes*60 = 720 Bytes. If I send more (in the loop giving 61 for example) it cause some residue and the PC doesn't made what I need. Otherwise, If I send less than 720 Bytes it works correctly.
    Do you know why is that?

    Thanks!!

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: DataOutputStream max number of bytes written

    What happens when you send more than 720 bytes? What do you see that shows a problem?

    The posted code has syntax errors.
    What package is the DataOutputStream class in?
    Last edited by Norm; 03-02-2017 at 10:20 PM.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: DataOutputStream max number of bytes written

    That is well below typical MTU sizes for networking. It is also well below what TCP and IP can accommodate. SO the problem lies elsewhere.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: DataOutputStream max number of bytes written

    Could you explain what:
    "...it cause some residue and the PC doesn't made what I need."
    means?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    jvb2008 is offline Member
    Join Date
    Mar 2017
    Posts
    9
    Rep Power
    0

    Default Re: DataOutputStream max number of bytes written

    Hello all,

    Once I send the 720B to the PC software (Tablet --> PC), PC send the tablet by DataInputStream several data. Once tablet receives all, tablet uses the same DataOutPutStream "Out1" in order to keep inform the PC by "ACK" that the data received is done correctly. If I send more than 720B the software doesn't recognize correctly the ACK, and with less than 720B yes. This is why I supose that DataOutPutStreams maybe has maximum bytes for sending or there is some residue.
    Could you help me with this?

    Thanks a lot,

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: DataOutputStream max number of bytes written

    What does "...the software doesn't recognize correctly the ACK..." mean?
    You will need to show us exactly what it is receiving compared to what is being sent.

    If you don't have that data, then you need to add logging to both ends so that you can trace the flow of data, and monitor what exact values are being sent and received.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: DataOutputStream max number of bytes written

    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    jvb2008 is offline Member
    Join Date
    Mar 2017
    Posts
    9
    Rep Power
    0

    Default Re: DataOutputStream max number of bytes written

    Hello all,

    The process of my sending is this:

    TABLET -- > PC: i send some data with my DataOutputStream
    PC --> TABLET : i receive (from PC) an ACK confirming that what I have sent from tablet is OK (I receive this data with my DataInputStream)
    TABLET --> PC: I send some data (1440 BYTES, sorry before i told you wrong) with the already created and used DataOutputStream.
    PC -- > TABLET: I receive from PC some data with the already created and used DataInputStream.
    TABLET --> PC: If what I received from PC is OK I send and ACK to the PC confirming the good sending with the already created and used DataInputStream,
    PC: The PC, when receives this ACK closes the communication. In this step, if before I sent more than 1440B (via my DataOutputStream) then the PC doesn't recognize my ACK and the PC's software doesn't close correctly the communication. Otherwise, if I send less than 1440B the PC recognize the ACK and closes correctly the communication.



    This is my code:

    public void dataSend(DataOutputStream out) {

    try {

    out.writeInt(swap4(130));

    //If loop goes till 120 (TOTAL 1440B) it works correctly, if loop goes till more than 120 (TOTAL more than 1440B) works incorrectly
    for (int i = 0; i < 130; i++) {
    out.write(hexStringToByteArray("0100"));
    out.write(hexStringToByteArray("54"));
    out.write(hexStringToByteArray("1102180D00"));
    out.write(hexStringToByteArray("535D"));
    out.write(hexStringToByteArray("5F1E"));

    out.flush();
    }


    } catch (Exception e) {
    Log.i("Error", "ERROR" + e);
    }


    I would thank you a lot your help,



    Thanks and regards,

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: DataOutputStream max number of bytes written

    Again, you need to actually debug this.

    The computer isn't suddenly going to fail to understand some piece of data.
    Something is going on, and to find out what you need hard data.
    So, log the data as it is sent, and log the data as it arrives.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  12. #12
    jvb2008 is offline Member
    Join Date
    Mar 2017
    Posts
    9
    Rep Power
    0

    Default Re: DataOutputStream max number of bytes written

    Hello again,

    I have spied what i am sending from the tablet to PC.
    - The first frame block sends 120 (HEX 78000000 in LittleEndian) times the same frame (TOTAL 1440B).
    - The second frame block sends 121 (HEX 79) times the same frame (TOTAL 1452B)
    Frame is 0100541102180d00535d5f1e.

    As you see, in the second frame block, the last 12 bytes (1452 - 1440 = 12B) is sending in another row. Could it affect to bad working? Could it be any problem in the type of OutPutStream that I am using? How I can send in the same row the last 12B?

    Thanks and regards,

    This first frame block works correctly:

    0000
    780000000100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e0100541102180d00535d 5f1e0100541102180d00535d5f1e0100541102180d00535d5f 1e0100541102180d00535d5f1e0100541102180d00535d5f1e 0100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e0100541102180d00535d 5f1e0100541102180d00535d5f1e0100541102180d00535d5f 1e0100541102180d00535d5f1e0100541102180d00535d5f1e 0100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e0100541102180d00535d 5f1e0100541102180d00535d5f1e0100541102180d00535d5f 1e0100541102180d00535d5f1e0100541102180d00535d5f1e 0100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e0100541102180d00535d 5f1e0100541102180d00535d5f1e0100541102180d00535d5f 1e0100541102180d00535d5f1e0100541102180d00535d5f1e 0100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e


    This second frame block doesn't work correctly:

    0000
    790000000100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e0100541102180d00535d 5f1e0100541102180d00535d5f1e0100541102180d00535d5f 1e0100541102180d00535d5f1e0100541102180d00535d5f1e 0100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e0100541102180d00535d 5f1e0100541102180d00535d5f1e0100541102180d00535d5f 1e0100541102180d00535d5f1e0100541102180d00535d5f1e 0100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e0100541102180d00535d 5f1e0100541102180d00535d5f1e0100541102180d00535d5f 1e0100541102180d00535d5f1e0100541102180d00535d5f1e 0100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e0100541102180d00535d 5f1e0100541102180d00535d5f1e0100541102180d00535d5f 1e0100541102180d00535d5f1e0100541102180d00535d5f1e 0100541102180d00535d5f1e0100541102180d00535d5f1e01 00541102180d00535d5f1e0100541102180d00535d5f1e0100 541102180d00535d5f1e0100541102180d00535d5f1e010054 1102180d00535d5f1e0100541102180d00535d5f1e01005411 02180d00535d5f1e0100541102180d00535d5f1e0100541102 180d00535d5f1e0100541102180d00535d5f1e010054110218 0d00535d5f1e0100541102180d00535d5f1e0100541102180d 00535d5f1e0100541102180d00535d5f1e0100541102180d00 535d5f1e0100541102180d00535d5f1e0100541102180d0053 5d5f1e0100541102180d00535d5f1e01005411
    02180d00535d5f1e

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: DataOutputStream max number of bytes written

    There are a lot of questions about your program:
    Where and how do you see any problem? Is there an exception? What happens?
    What code detects the problem? Why does that code think there is a problem?

    What was the purpose for posting all that hex data? There are very few here that are going to look at that hex data.
    If you don't understand my response, don't ignore it, ask a question.

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: DataOutputStream max number of bytes written

    Don't just spy.
    Add debugging in the actual code so you can catch what gets sent, and what is received, and how it looks when it arrives.

    It's not going to be the network.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  15. #15
    jvb2008 is offline Member
    Join Date
    Mar 2017
    Posts
    9
    Rep Power
    0

    Default Re: DataOutputStream max number of bytes written

    With the Hex data I want to show you only the quick visual difference between my two block of data (it is not necesary to look the hex data).

    1. The first one (sending 1440B or less) the destination (PC) detects correctly the ACK.
    2. The second one (sending more than 1440B) the destination (PC) doesn't detect correctly the ACK.

    Please realize that in the second one, the last (12B) (02180d00535d5f1e) have suffered a line break (I don't know why). I think it could be the reason. So my questions are:
    Could it affect to bad working? Could it be any problem in the type of OutPutStream that I am using? How I can send in the previous row the last 12B?

  16. #16
    jvb2008 is offline Member
    Join Date
    Mar 2017
    Posts
    9
    Rep Power
    0

    Default Re: DataOutputStream max number of bytes written

    *sorry, the last 8B have suffered the line break (not the last 12B) (02180d00535d5f1e)

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: DataOutputStream max number of bytes written

    destination (PC) doesn't detect correctly the ACK.
    Why? What does the code see that is not correct?
    Is there an ACK? Where is the ACK that the program does not see it?
    If you don't understand my response, don't ignore it, ask a question.

  18. #18
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: DataOutputStream max number of bytes written

    Quote Originally Posted by jvb2008 View Post
    Could it affect to bad working? Could it be any problem in the type of OutPutStream that I am using? How I can send in the previous row the last 12B?
    You're not listening to folks. You need to put in some print statements to aid in debugging. Are you printing each line as it is transmitted? What app is receiving the data? Can you monitor incoming data on the destination app?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  19. #19
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: DataOutputStream max number of bytes written

    You're sending bytes...where does a line break come into things?
    There's no such thing, unless the protocol you are using says so.

    From my stand point you seem to be focussing heavily on the bytes, and not on the data (of that makes any sense).
    You see there is an issue (apparently) in the byte data, and you seem stuck staring at that. I'm trying to say you need to see exactly what has been sent.

    At both ends.
    You need to debug the code on the PC that is receiving this data, as well as the code on the tablet.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  20. #20
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: DataOutputStream max number of bytes written

    Does this work with all data? Why not transmit over 720 bytes of the same character?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Page 1 of 2 12 LastLast

Similar Threads

  1. DataOutputStream
    By blaqkout in forum New To Java
    Replies: 0
    Last Post: 10-02-2011, 07:27 PM
  2. Dataoutputstream
    By saranyabaskaran in forum New To Java
    Replies: 6
    Last Post: 02-12-2011, 02:26 AM
  3. How to read a fixed number of bytes in a DataInputStream
    By Michailangelo in forum Networking
    Replies: 4
    Last Post: 06-29-2010, 02:13 AM
  4. File I/O with DataOutputStream
    By Tzaphiel in forum New To Java
    Replies: 0
    Last Post: 12-16-2007, 09:39 PM
  5. how to know the number of bytes
    By gabriel in forum New To Java
    Replies: 2
    Last Post: 08-06-2007, 05:13 PM

Posting Permissions

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