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. how to send a struct

how to send a struct

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
6 Posts 5 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.
  • H Offline
    H Offline
    hanlei0000000009
    wrote on last edited by
    #1

    send function only send char*, how to send a struct. thanks!

    W R T H 4 Replies Last reply
    0
    • H hanlei0000000009

      send function only send char*, how to send a struct. thanks!

      W Offline
      W Offline
      Waldermort
      wrote on last edited by
      #2

      you need to write each member to a char buffer, then send that

      1 Reply Last reply
      0
      • H hanlei0000000009

        send function only send char*, how to send a struct. thanks!

        R Offline
        R Offline
        Rinu_Raj
        wrote on last edited by
        #3

        Can you please explain what you really need ? Rinu Raj

        1 Reply Last reply
        0
        • H hanlei0000000009

          send function only send char*, how to send a struct. thanks!

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #4

          a struct, is finally an array of bytes. and a char* is also such a thing. the only thing to tell to send is how much bytes (chars) it will have to send, with sizeof(YourStruct).


          TOXCCT >>> GEII power

          [VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]

          N 1 Reply Last reply
          0
          • T toxcct

            a struct, is finally an array of bytes. and a char* is also such a thing. the only thing to tell to send is how much bytes (chars) it will have to send, with sizeof(YourStruct).


            TOXCCT >>> GEII power

            [VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]

            N Offline
            N Offline
            Niklas L
            wrote on last edited by
            #5

            ...that is after he takes care of byte order issues on each member.

            net

            1 Reply Last reply
            0
            • H hanlei0000000009

              send function only send char*, how to send a struct. thanks!

              H Offline
              H Offline
              hanlei0000000009
              wrote on last edited by
              #6

              i using this method: send(s, (char*)&my_struct, sizeof(my_struct), 0); thanks all for help!

              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