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#
  4. XML via Socket?

XML via Socket?

Scheduled Pinned Locked Moved C#
xmlquestion
7 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.
  • R Offline
    R Offline
    rbarzallo
    wrote on last edited by
    #1

    Hi, Is posible send XML via Socket? Where can I found documentation about this? Thanks

    C J 2 Replies Last reply
    0
    • R rbarzallo

      Hi, Is posible send XML via Socket? Where can I found documentation about this? Thanks

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      rbarzallo wrote: Is posible send XML via Socket? Yes, you can send any stream of bytes via a socket. However, using higher level methods may be more appropriate. rbarzallo wrote: Where can I found documentation about this? Well, if you already know how to use sockets it is very simple. All you need to do is to convert the string (Encode[^]) to a byte array and then send it. (You'll find other Encoders and Decoders in the System.Text namespace if UTF8 is not what you are looking for - I just chose UTF8 because Visual Studio defaults to that character encoding for XML files.). At the other end you receive the bytes and convert them (Decode[^]) to a string. Does this help?


      "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871)

      1 Reply Last reply
      0
      • R rbarzallo

        Hi, Is posible send XML via Socket? Where can I found documentation about this? Thanks

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        Sure. But really you probably don't want to use sockets directly as that's fairly low level. You might want to use System.Runtime.Remoting to pass objects (presumably containing XML data) across to another machine. FYI, if you use remoting over HTTP, all data packets are sent in a stream of XML anyway. The other option is using remoting over the TCP channel, in which data gets sent as a stream of binary formatted data. If you're looking for more info on remoting, MSDN has some good examples, and you might also want to check out Ingo Rammer's remoting site[^]. --------------------------- He who knows that enough is enough will always have enough. -Lao Tsu

        H 1 Reply Last reply
        0
        • J Judah Gabriel Himango

          Sure. But really you probably don't want to use sockets directly as that's fairly low level. You might want to use System.Runtime.Remoting to pass objects (presumably containing XML data) across to another machine. FYI, if you use remoting over HTTP, all data packets are sent in a stream of XML anyway. The other option is using remoting over the TCP channel, in which data gets sent as a stream of binary formatted data. If you're looking for more info on remoting, MSDN has some good examples, and you might also want to check out Ingo Rammer's remoting site[^]. --------------------------- He who knows that enough is enough will always have enough. -Lao Tsu

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          The transport channel (HTTP or TCP) has nothing to do with the format of the data. This depends on what formatter you specify in your remoting configuration. Both a SoapFormatter and BinaryFormatter are provided in the FCL and can be used for any transport channel (unless some third-party transport channel is anal about that or something). The transport channels may default to a specific formatter, but it can be changed.

          Microsoft MVP, Visual C# My Articles

          J J 2 Replies Last reply
          0
          • H Heath Stewart

            The transport channel (HTTP or TCP) has nothing to do with the format of the data. This depends on what formatter you specify in your remoting configuration. Both a SoapFormatter and BinaryFormatter are provided in the FCL and can be used for any transport channel (unless some third-party transport channel is anal about that or something). The transport channels may default to a specific formatter, but it can be changed.

            Microsoft MVP, Visual C# My Articles

            J Offline
            J Offline
            Judah Gabriel Himango
            wrote on last edited by
            #5

            Right you are, I stand corrected. :) Typically, one would use a binary formatter for use over a TCP channel, and a SOAP formatter for use over an HTTP channel, but yeah you're right it doesn't have to be that way. --------------------------- He who knows that enough is enough will always have enough. -Lao Tsu

            1 Reply Last reply
            0
            • H Heath Stewart

              The transport channel (HTTP or TCP) has nothing to do with the format of the data. This depends on what formatter you specify in your remoting configuration. Both a SoapFormatter and BinaryFormatter are provided in the FCL and can be used for any transport channel (unless some third-party transport channel is anal about that or something). The transport channels may default to a specific formatter, but it can be changed.

              Microsoft MVP, Visual C# My Articles

              J Offline
              J Offline
              jqd2001
              wrote on last edited by
              #6

              Heath, I think in addition, Formatter sink are used to serialize IMessage, have nothing to do with the XML in IMessage. ie. You can even transmmit XML using BinaryFormatter. Transmitt XML using Socket is realistic since mobile device may not support remoting. Correct me if I am making mistakes Thanks James

              H 1 Reply Last reply
              0
              • J jqd2001

                Heath, I think in addition, Formatter sink are used to serialize IMessage, have nothing to do with the XML in IMessage. ie. You can even transmmit XML using BinaryFormatter. Transmitt XML using Socket is realistic since mobile device may not support remoting. Correct me if I am making mistakes Thanks James

                H Offline
                H Offline
                Heath Stewart
                wrote on last edited by
                #7

                No, you're not wrong, but I fail to see what you're getting at. The DataSet, for example, still serializes as XML even using the BinaryFormatter, but the only point I was making was that no specific formatter must be used with any specific transport channel.

                Microsoft MVP, Visual C# My Articles

                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