×

Discussion Board

Results 1 to 3 of 3

Threaded View

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    6

    Red face help sending file from PC to mobile

    im about sending an XML file into mobile. so file is transfered to mobile using wireless access point. im using fortune server and client(default sample from qt) to try it.

    i got this code on fortune server to change
    Code:
     void Server::sendFortune()
     {
         QByteArray block;
         QDataStream out(&block, QIODevice::WriteOnly);
         out.setVersion(QDataStream::Qt_4_0); out << (quint16)0;
         out << fortunes.at(qrand() % fortunes.size());
         out.device()->seek(0);
         out << (quint16)(block.size() - sizeof(quint16));
    QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
         connect(clientConnection, SIGNAL(disconnected()),
                 clientConnection, SLOT(deleteLater()));clientConnection->write(block);
         clientConnection->disconnectFromHost();
     }
    this function change data into Byte. if i want to send file, i must change file into byte. Anyone can help me how to change file into byte? ive done this but i dont know how to test.
    Code:
    void Server::sendFortune()
    {
        //QByteArray block;
        //QByteArray block("chibineji.jpg");
        QFile file("test.dat");
        file.open(QIODevice::WriteOnly);
        QDataStream filein(&file);
        QByteArray block;
        QDataStream out(&block, QIODevice::WriteOnly);
        out.setVersion(QDataStream::Qt_4_0);
    
        out << (quint16)0;
        //out << fortunes.at(qrand() % fortunes.size());
        //out << QString("what is it?");
        //out << (qint32)42;
        //out.~QDataStream(filein);
        out.device()->seek(0);
        out << (quint16)(block.size() - sizeof(quint16));
    
        QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
        connect(clientConnection, SIGNAL(disconnected()),
                clientConnection, SLOT(deleteLater()));
        clientConnection->write(block);
        clientConnection->disconnectFromHost();
    }
    my code is about adding variable filein(QDataStream) into out(QDataStream). but i havent find how to do it.
    Last edited by forent; 2010-03-05 at 01:29. Reason: adding words

Similar Threads

  1. Stream Video File from Mobile to PC
    By mobileteam in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2009-12-24, 05:58
  2. receive file from bluetooth (Mobile -> PC)
    By caucuk33 in forum Bluetooth Technology
    Replies: 4
    Last Post: 2008-07-11, 13:20
  3. File transfer from mobile to PC
    By iworktech_kiran in forum Mobile Java General
    Replies: 1
    Last Post: 2007-09-11, 13:54
  4. Contacts fields order??
    By timatima in forum Symbian
    Replies: 1
    Last Post: 2007-06-08, 13:51
  5. Replies: 1
    Last Post: 2005-05-26, 14:22

Posting Permissions

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