×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Sep 2006
    Posts
    54

    Problem with sending image

    hi guys,
    need help on this issue urgently. I have been on this problem for several days and does not seem to solve it.
    I am trying to send an image in descriptor over to laptop. I have converted the image to descriptor already. however the problem lies in the sending.

    Snippets of my code:
    //iMessage contains the technical details of my image, e.g the length
    iState = EMMSConnecting;
    iSendingSocket.Write(iMessage,iStatus);
    SetActive();

    //after asynchronous request
    void CCampusBluetoothClient::RunL()
    {
    if (iStatus.Int() == KErrNone)
    {
    switch (iState)
    {
    case EConnecting:
    {
    iMessage.Zero();
    SendMainMessage();
    break;
    }
    case EMessageSent:
    {
    NEikonEnvironment::MessageBox(_L("Part 2 sent"));
    ReceiveNotification();
    break;
    }
    case EMMSConnecting:
    {
    if(IsActive())
    {
    Cancel();
    }

    iState = EMessageSent;
    //sending the image
    iSendingSocket.Write(*iField3, iStatus);
    SetActive();

    break;
    }
    default:
    Panic(EInvalidClientState);
    break;
    }
    }
    else
    {
    Disconnect();
    iObserver.HandleErrorL(iStatus.Int());
    }
    }

    the problem here is after sending the technical details, I tried to send the image using the same socket. However, it appears the image is not send in full. The server which is the laptop keeps requesting for more data.
    However, if I were to send the image directly, the problem does not appear. Is it because I cannot send both the technical details and image on the same socket one after another without closing it first.
    Pls help!!!!I am really at my wits end

    Thanks
    ckt

  2. #2
    Registered User
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747

    Re: Problem with sending image

    I would suggest you to create some protocol by yourself and send all the information using a single buffer (remember Symbian Descriptor can hold binary data as well) as a chunk of data. The format of your message would look something like this:

    +-----------------------------+
    | HEADER | MESSAGE | TAILER |
    +-----------------------------+

    If the above mentioned doesn't satisfy your needs then other thing is you've only given one part of your code, I would like to see the second part (the server on the laptop).

  3. #3
    Regular Contributor
    Join Date
    Sep 2006
    Posts
    54

    Re: Problem with sending image

    Hi vin2ktalks,
    finally see a reply and I am so glad. Thks for your reply!!!!
    I would definitely wish to create my own protocol. But the limitations is it appears using TBuf there is a limit to the size that it could be created. As I am sending image, the size would be in 100000. However, whenever i create such a descriptor, my hp would shutdown. If I were to create using HBuf, I would not be able to append data when it comes along. Meaning, I cant combine the details with the image together in 1 HBuf as complete replacement of HBuf is required. Is there any way to go ard this?
    My server is using java

    Snippets of my server code:
    class ServerConnection extends Thread
    {
    DataInputStream in;
    DataOutputStream out;
    StreamConnection connection;

    public ServerConnection(StreamConnection c)
    {
    try
    {
    connection = c;
    in = connection.openDataInputStream();
    out = connection.openDataOutputStream();
    SPP_Server.upConns();
    this.start();
    } catch (Exception e)
    {
    e.printStackTrace();
    BlueCampusFrame.log(e.getMessage());
    }
    }

    public void run()
    {
    int temp=0;
    int sizeBuf=0;
    try
    {
    BlueCampusFrame.log("accepted a client connection. reading it...e");
    byte[] msg = new byte[1000000];

    //reading the size of expected msg
    in.read(msg,0,4);
    sizeBuf=(msg[temp++]<<0)+(msg[temp++]<<8)+(msg[temp++]<<16)+(msg[temp++]<<24);

    String myString = Integer.toString(sizeBuf);
    BlueCampusFrame.log(myString);

    //reading the whole chunk of data
    in.read(msg,0,sizeBuf);
    BlueCampusFrame.log("after reading");
    .......
    }
    }

    The server basically will first read the technical details to determine the expected size of the image to be received. Subsequently it will read in the whole image.
    This code works when I am sending small data such as 512bytes. However, when it is an image, the server will hang waiting for more data. I am not sure if it is due to huge amount of data being sent that hangs the server

    Regards
    ckt

  4. #4
    Regular Contributor
    Join Date
    Sep 2006
    Posts
    54

    Re: Problem with sending image

    Hi,
    or maybe anyone can enlighten me on the sending of images over RFComm. Apparently, there are a lot of questions being asked on this but not much solutions. Can anyone who have successfully implemented share ur experience here.
    For a start, I know that to transfer, the image have to be converted to a descriptor before it is sent. For me, i did the conversion using CImageEncoder:ataNewL(). After converting, i tried to send the descriptor created via a stream connection but it does not work. It appears small data can be send over RFComm but huge data poses problem. Can anyone help?

    Thanks

    Regards,
    ckt

  5. #5
    Registered User
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747

    Re: Problem with sending image

    Quote Originally Posted by ckt
    Hi,
    ...i tried to send the descriptor created via a stream connection but it does not work. It appears small data can be send over RFComm but huge data poses problem. ...
    Why can't you split the whole data to some small part and send. Please specify the total length of the image buffer (MESSAGE PART), and other attributes in the HEADER PART. While receiving always read the header first (say for eg 10 bytes) from that information find out the length of the image buffer (MESSAGE), again shoot a read operation with the length of the image buffer and read it from the socket. I haven't worked much with JAVA. I hope there would be some problem in your JAVA code, as the C++ code seems ok.

    Another suggestion is to use OBEX over RFComm for sending a file. I've just started a project on SourceForge for that purpose if you've interested you can have a look: BTFileSend.

  6. #6
    Regular Contributor
    Join Date
    Sep 2006
    Posts
    54

    Re: Problem with sending image

    hi vin2ktalks,
    thks for replying again.
    Yup, I can spilt the data to be sent into smaller chunks and send. However, when the pc is to send back the image to the phone, how does the phone collect all the data and place into a single HBufC and restore the image using CImageDecoder?
    From my debugging, it appears that large data cannot be sent over RFComm. Is there a limit on the amount of data that can be send over such a port? Apparently only about 10700bytes is transmitted. Subsequently the server stops, waiting for more data where my client apparently has send the required data already. Is there any MTU that I have to set for RFComm??

    Regards
    ckt

Similar Threads

  1. problem in getting the image through URL
    By lakshmanraob in forum Mobile Java General
    Replies: 1
    Last Post: 2005-10-04, 10:28
  2. Replies: 3
    Last Post: 2004-04-20, 07:40
  3. HELP! problem w/ sending and reading sms..
    By mauve928 in forum General Messaging
    Replies: 0
    Last Post: 2003-12-14, 19:10
  4. Problem of drawing FLIPPED Image after clipping in Nokia 3510i handset
    By radhesh in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2003-12-10, 03:29
  5. 7650 Image Uploader strange problem
    By kamlesh_in in forum Symbian
    Replies: 1
    Last Post: 2003-08-25, 15:06

Posting Permissions

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