Results 1 to 5 of 5

Thread: Image transfer using QTcpsocket

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2015
    Posts
    2
    Platforms
    Unix/X11

    Default Re: Image transfer using QTcpsocket

    Thanks for your reply..

    I am working client server app..
    Chat is working properly even i am able transfer text file..
    But facing problem with image..

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Image transfer using QTcpsocket

    So if you want to write your own server that sends images to clients, you'll need to do the following:

    For the server:

    • Use QTcpServer and listen to a known TCP/IP port number greater than 1024
    • Read the image filename sent by the client and verify it exists
    • Open the image file, read the binary data and send to the client
    • Close the connection to the client once the data is sent


    For the client:

    • Use QTcpSocket and connect to the server via ip addr or hostname and known port that server is listening to
    • Send the image filename you want to receive to the server
    • Read data from the socket and save to local file
    • Close the file once the server closes the connection


    Since TCP/IP is stream oriented, you will typically precede each request with some metadata about the data that follows so that you can determine when you have received a complete request. For example, I'd precede the actual image data with the length of the image file, so you can verify you receive the full image file, etc.

    If you don't know how to get started, you have a challenge ahead of you. Google around for some Qt TCP/IP client/server examples and study the examples provided by Qt as well.

    Good luck.

  3. #3
    Join Date
    May 2015
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: Image transfer using QTcpsocket


Similar Threads

  1. Replies: 0
    Last Post: 18th August 2011, 04:36
  2. QTcpSocket gzip and Transfer chunked
    By giusepped in forum Qt Programming
    Replies: 0
    Last Post: 10th August 2011, 16:41
  3. QTcpSocket problem in file transfer
    By omprakash in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2010, 08:18
  4. File Transfer with QTcpServer and QTcpSocket
    By NoRulez in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2009, 17:12
  5. QTcpSocket & transfer errors
    By jkam in forum Qt Programming
    Replies: 1
    Last Post: 20th July 2008, 20:42

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
  •  
Qt is a trademark of The Qt Company.