×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    4

    sending a snapshot array byte to server

    hi all

    I am trying to send a snapshot array byte from a MIDlet to a pc. My problem is that i cannot receive the array byte completely.

    my shapshot is taken using this code:
    Code:
    byte[] image = videoCon.getSnapshot(null);

    my outputstream to send the array byte looks like:
    Code:
    stream = (StreamConnection)Connector.open(url);
      OutputStream out = stream.openOutputStream();
      out.write(image);  
      out.close();
      stream.close();
    and my server has the following to receive the stream:
    Code:
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    System.out.println("3:"+bis);
    byte b;
    while ((b=(byte)bis.read())!= -1){
    	System.out.println(b);
    	baos.write(b);
    }
    System.out.println(b);
    System.out.println("writing to file");
    byte[]imgByte = baos.toByteArray();
    where bis is the bufferedinputstream

    i know the code works since i have tried sending an array comprising only of strings, whatever the length, and i can receive it all.
    but for the case of the array of bytes, i do not get the whole array, only a very small part of it.

    my objective is taking a picture from a midlet, and sending that picture to a server and save somewhere.

    if anyone got an idea of whats wrong or another way of doing this, i would be really greatful
    thanks in advance

    jin a

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Posts
    122

    Re: sending a snapshot array byte to server

    Hey,

    Try to split it into a payload of 250bytes and send it.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    4

    Re: sending a snapshot array byte to server

    hello, thanks for your reply

    i have no experience with payload, i am currently searching for some material on it, to try what you just said...

    if u have any links or materials on this please let me know

    thanks in advance
    jin a

  4. #4
    Regular Contributor
    Join Date
    Dec 2007
    Posts
    122

    Re: sending a snapshot array byte to server

    1)allocate a buffer of 250 bytes (for example, just keep it small)
    2) //DO THAT IN A SEND THREAD
    Code:
      n_bytes_sent = 0;
      while (n_bytes_sent< imagesize)
        bytes_left = imagesize - n_bytes_sent;
        if(bytes_left>=250)
           n_2_copy = 250;
        else
           n_2_copy = bytes_left;
       
        copy(my_buffer, from_image_bytes_array, n_2_copy, n_bytes_sent);
        send(my_buffer);
        n_bytes_sent += 250;
        sleep(200);

Similar Threads

  1. Uploading Snapshot byte array to server.
    By krem82 in forum Mobile Java Networking & Messaging & Security
    Replies: 28
    Last Post: 2009-03-13, 20:12
  2. Byte Array
    By fuhrer in forum Symbian
    Replies: 4
    Last Post: 2007-10-19, 11:01
  3. TCP server packet receiving problem
    By raj_rr7 in forum Symbian Networking & Messaging (Closed)
    Replies: 9
    Last Post: 2007-07-12, 12:24
  4. limit to size of byte array that can be transmitted?
    By dleeICT in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-03-15, 11:17
  5. Sending MMS from own server
    By iconaphone in forum General Messaging
    Replies: 1
    Last Post: 2002-10-29, 09:26

Posting Permissions

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