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. Other Discussions
  3. IT & Infrastructure
  4. sending classe or struct with socket!

sending classe or struct with socket!

Scheduled Pinned Locked Moved IT & Infrastructure
question
4 Posts 4 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.
  • A Offline
    A Offline
    a_hic
    wrote on last edited by
    #1

    hi, I am a new socket programmer, I know that socket allow sending buffer of char by send(), if I wont to send a struct or whole class, how I do it? thanks.

    B M M 3 Replies Last reply
    0
    • A a_hic

      hi, I am a new socket programmer, I know that socket allow sending buffer of char by send(), if I wont to send a struct or whole class, how I do it? thanks.

      B Offline
      B Offline
      Brian Delahunty
      wrote on last edited by
      #2

      You'd probably get a lot more responses if you posted this in the C++ message board :)


      "Isn't that the "write once, debug everywhere" language?" Tom Archer on Java... :)

      1 Reply Last reply
      0
      • A a_hic

        hi, I am a new socket programmer, I know that socket allow sending buffer of char by send(), if I wont to send a struct or whole class, how I do it? thanks.

        M Offline
        M Offline
        mystro_AKA_kokie
        wrote on last edited by
        #3

        I don't know if there's a simple way to send an object over sockets,but u may want to send the individual data members and reconstruct the object on the receiving end.

        1 Reply Last reply
        0
        • A a_hic

          hi, I am a new socket programmer, I know that socket allow sending buffer of char by send(), if I wont to send a struct or whole class, how I do it? thanks.

          M Offline
          M Offline
          Mukkie
          wrote on last edited by
          #4

          You may send whole struct, just as byte buffer. With class, You will have a problem, cause it is impossible to get object instance address and send sizeof(class_type) bytes (or maybe - it is possible but won't work). In such case, send class identification (what class is this ; some define, etc) and all the data which are required to fully recreate class instance on the other side. Mukkie

          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