Results 1 to 3 of 3
  1. #1
    sangio85 is offline Member
    Join Date
    Dec 2010
    Rep Power

    Default Very strange exception in a socket comunication

    Hi guys.
    I have a problem. I'm running two threads on a server where I get the client a command string and then under the command because I do an action.
    In particular, I get two xml files from the client.
    In one case I have no problem. The file is properly received.
    In the other case rather than have a very strange because everything is exactly the same as the first case:

    the code is:

    XML Code:
    if("I SENT THE ACTIONS".equals(str)){
    System.out.println("S: CLIENT TELL: '" + str + "'");
    byte [] mybytearray2 = new byte [filesize];
    InputStream is2 = client.getInputStream();
    FileOutputStream fos2 = new FileOutputStream("AZIONITOSERVER.xml");
    BufferedOutputStream bos2 = new BufferedOutputStream(fos2);
    bytesRead2 =,0,mybytearray2.length);
    current2 = bytesRead2;
    do {
    bytesRead2 =, current2, (mybytearray2.length-current2));
    if(bytesRead2 >= 0) current2 += bytesRead2;
    } while(bytesRead2 > -1);
    bos2.write(mybytearray2, 0 , current2);
    long end = System.currentTimeMillis();
    The excepition is:
    L'eccezione che mi capita :

    at java.lang.System.arraycopy(Native Method)
    at Source)
    at java:104)
    at Source)

    where the row is:
    bos2.write(mybytearray2, 0 , current2);

    The strange thing is that, when not the first thread that is the identical one to this, this exception does not happen and everything works, just that I need to run both threads.
    Thaks at alla.

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    San Jose, CA, USA
    Rep Power


    how about:

    Java Code:
    bos2.write(mybytearray2, 0 , current2 - 1);
    My Hobby Project: LegacyClone

  3. #3
    sangio85 is offline Member
    Join Date
    Dec 2010
    Rep Power


    I'm really sorry but there is no change in the exception and in my program if I do:
    bos2.write(mybytearray2, 0 , current2-1);

    I will became mad with this type of excemption....

Similar Threads

  1. How to handle socket Exception
    By mayank0512 in forum Networking
    Replies: 14
    Last Post: 12-22-2010, 12:31 AM
  2. Comunication between client
    By smi in forum Networking
    Replies: 3
    Last Post: 06-14-2010, 03:39 PM
  3. unreported exception (socket connection)
    By Symbiot in forum New To Java
    Replies: 7
    Last Post: 05-28-2010, 12:13 PM
  4. Comunication with server
    By Quillion in forum New To Java
    Replies: 2
    Last Post: 11-09-2009, 11:07 PM
  5. strange swt exception
    By ahmed.kotb in forum SWT / JFace
    Replies: 0
    Last Post: 04-23-2009, 11:15 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