Results 1 to 6 of 6

Thread: Why i can't get the file.

  1. #1
    Join Date
    Jun 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Why i can't get the file.

    Qt Code:
    1. //client.cpp
    2. //..........................
    3. connect(senderButton, SIGNAL(clicked()), this, SLOT(sendMessageSlot()));
    4. void Send::sendMessageSlot()
    5. {
    6.  
    7. QDataStream out(client);
    8. QFileInfo info(file->fileName());
    9. out << info.fileName() << currentSize;
    10.  
    11. while(!file->atEnd())
    12. {
    13. char schar[2048];
    14. if (currentSize >= 2048)
    15. {
    16. file->read(schar, 2048);
    17. client->write(schar, 2048);
    18. currentSize-=2048;
    19. }
    20. else if(currentSize < 2048)
    21. {
    22. file->read(schar, currentSize);
    23. client->write(schar, currentSize);
    24. break;
    25. }
    26. }
    27. file->close();
    28. }
    29. ------------------------------------------------------------------------------------
    30. //server.cpp
    31. //...........
    32. connect(server, SIGNAL(readyRead()), this, SLOT(newMessageSlot()));
    33. void Receive::newMessageSlot()
    34. {
    35. if (boo_new)
    36. {
    37. QDataStream in(server);
    38. in >> name >> allSize;
    39. boo_new = false;
    40. }
    41.  
    42. file = new QFile(QString("C:\\%1").arg(name), this);
    43. file->open(QIODevice::WriteOnly |QIODevice::Append);
    44.  
    45.  
    46. if (server->isReadable())
    47. {
    48. quint64 size = server->bytesAvailable();
    49. char buf[size];
    50. server->read(buf, size);
    51. file->write(buf, size);
    52. readSize += size;
    53.  
    54. }
    55. file->close();
    56. delete file;
    57. if (readSize == allSize)
    58. {
    59. QMessageBox::warning(this, "ok", QString::fromLocal8Bit("over"));
    60. return;
    61. }
    62. }
    To copy to clipboard, switch view to plain text mode 

    ----------------------------------------------------------
    I am from in china, my English is very ppor, pardon me!
    compile and run it.
    i can get file in server from client send in local area network
    buf i can't get file in server from client send in internet...

    why ?
    i did't understand English, please reply some correct codes...

    thank very very much............

    //if you want to make china friends, please add me
    //janlex@msn.com
    Last edited by wysota; 28th September 2006 at 13:06. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why i can't get the file.

    Could be a firewall issue.

  3. #3
    Join Date
    Jun 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Why i can't get the file.

    if in internet, i can just only get a litte bytes..

    i was make sure that it has problem without firewall

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Why i can't get the file.

    maybe a timeout issue then...

  5. #5
    Join Date
    Jun 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Why i can't get the file.

    what can i do?

    who can tell me that the problem...

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Why i can't get the file.

    Do example network programs bundled with Qt work fine for you over the net?

Similar Threads

  1. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47
  2. .ui file name and classname
    By Rekha in forum Newbie
    Replies: 3
    Last Post: 12th August 2006, 01:53
  3. SQLite-DB in a qrc file
    By Lykurg in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2006, 19:24
  4. File permission QFile::WriteOther on Win Dos
    By patrik08 in forum Newbie
    Replies: 1
    Last Post: 13th June 2006, 14:16
  5. QHttp GET File & Password
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 11th June 2006, 13:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.