Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Image transwering using CAsyncsoc

Image transwering using CAsyncsoc

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    psramu
    wrote on last edited by
    #1

    Hi this is ramu I got a problem in transwering the image buffer. Actually the problem is at receiving side. The receive statement not receiving the whole data sent. Some body advised to send the length as a heder first and get it at the client side and make a loop untill the whole length is received. But i dont know how to make the length as heade in serverside to send and how to put the receive statement in loop. So please some body help me out in this problem. Thank you. Ramu

    K 1 Reply Last reply
    0
    • P psramu

      Hi this is ramu I got a problem in transwering the image buffer. Actually the problem is at receiving side. The receive statement not receiving the whole data sent. Some body advised to send the length as a heder first and get it at the client side and make a loop untill the whole length is received. But i dont know how to make the length as heade in serverside to send and how to put the receive statement in loop. So please some body help me out in this problem. Thank you. Ramu

      K Offline
      K Offline
      kakan
      wrote on last edited by
      #2

      There are several ways. An easy way could be by sending i.e. an unsigned long (if has the capacity needed) as the first data. Kind of like this: Sending side unsigned long datalength = imageLength; Send(&datalength, sizeof(unsigned long)); while(moreDataToSend) { send(data); } At the receiving side (assuming that the Read function returns the number of bytes read from the socket): unsigned long receivedDataLength; Read(&receivedDataLength, sizeof(unsigned long)); unsigned long receivedBytes = 0L; while(receivedBytes < receivedDataLength) { receivedBytes += (unsigned long) Read(buffer, sizeof(buffer); // Do something with buffer } If an unsigned long isn't enough, the use some other variable type. Just make sure it's the same on both sides.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups