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. Managed C++/CLI
  4. C# send structure objects through socket

C# send structure objects through socket

Scheduled Pinned Locked Moved Managed C++/CLI
questioncsharpgame-devsysadminlounge
6 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.
  • I Offline
    I Offline
    ikurtz
    wrote on last edited by
    #1

    i have done a bit of reading in client/server programming in c#. i am familiar enough with this process to ask the following question: how do i transmit structure objects through tcp/ip instead of just strings? my app is a networked game with chat capabilities. so instead of just transmitting text, i would like to imploy a data structure or class structure that will have two fields: i. packet type ii. the data for the packet type and i would transmit this when needed during the execution of the application, and decode the data object at the receiving end and place it where it belongs. im not looking for code, just some ideas and search statements i can feed to google so i will; have a better understanding. ive read about serialisation/de serialisation, is that he way to go? thanks.

    P N 2 Replies Last reply
    0
    • I ikurtz

      i have done a bit of reading in client/server programming in c#. i am familiar enough with this process to ask the following question: how do i transmit structure objects through tcp/ip instead of just strings? my app is a networked game with chat capabilities. so instead of just transmitting text, i would like to imploy a data structure or class structure that will have two fields: i. packet type ii. the data for the packet type and i would transmit this when needed during the execution of the application, and decode the data object at the receiving end and place it where it belongs. im not looking for code, just some ideas and search statements i can feed to google so i will; have a better understanding. ive read about serialisation/de serialisation, is that he way to go? thanks.

      P Offline
      P Offline
      Paulo Zemek
      wrote on last edited by
      #2

      See serialization and deserialization of objects. I use BinaryFormatter for this job.

      I 1 Reply Last reply
      0
      • P Paulo Zemek

        See serialization and deserialization of objects. I use BinaryFormatter for this job.

        I Offline
        I Offline
        ikurtz
        wrote on last edited by
        #3

        i just read the following: The Binary Formatter The Binary formatter provides binary encoding for compact serialization either for storage or for socket-based network streams. The BinaryFormatter class is generally not appropriate when data is meant to be passed through a firewall. -------------------- is Xml Serialization good for going through firewalls?

        M 1 Reply Last reply
        0
        • I ikurtz

          i just read the following: The Binary Formatter The Binary formatter provides binary encoding for compact serialization either for storage or for socket-based network streams. The BinaryFormatter class is generally not appropriate when data is meant to be passed through a firewall. -------------------- is Xml Serialization good for going through firewalls?

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          ikurtz wrote:

          The BinaryFormatter class is generally not appropriate when data is meant to be passed through a firewall.

          I don't see that in the documentation for the BinaryFormatter class[^] If you're using sockets, you already have an issue with firewalls. If you can connect the sockets, then the data you put over the wire isn't an issue - socket data is always binary. The binary formatter is for converting your objects to/from binary (binary serialization).

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          I 1 Reply Last reply
          0
          • M Mark Salsbery

            ikurtz wrote:

            The BinaryFormatter class is generally not appropriate when data is meant to be passed through a firewall.

            I don't see that in the documentation for the BinaryFormatter class[^] If you're using sockets, you already have an issue with firewalls. If you can connect the sockets, then the data you put over the wire isn't an issue - socket data is always binary. The binary formatter is for converting your objects to/from binary (binary serialization).

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            I Offline
            I Offline
            ikurtz
            wrote on last edited by
            #5

            thats exactly what i thought (after some thought!). because the data is embedded it should not make a difference. well one comes across all kinds of statements made on the web. one has to be able to use ones judgement also. :)

            1 Reply Last reply
            0
            • I ikurtz

              i have done a bit of reading in client/server programming in c#. i am familiar enough with this process to ask the following question: how do i transmit structure objects through tcp/ip instead of just strings? my app is a networked game with chat capabilities. so instead of just transmitting text, i would like to imploy a data structure or class structure that will have two fields: i. packet type ii. the data for the packet type and i would transmit this when needed during the execution of the application, and decode the data object at the receiving end and place it where it belongs. im not looking for code, just some ideas and search statements i can feed to google so i will; have a better understanding. ive read about serialisation/de serialisation, is that he way to go? thanks.

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              As others said, you can use binary serialization to send data over the wire. But take a look at projects like Protocol Buffers[^] also. There is a .NET port available and it makes data transmission easy and it does serialization and deserialization for you.

              Best wishes, Navaneeth

              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