XML via Socket?
-
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)
-
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
-
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
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
andBinaryFormatter
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
-
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
andBinaryFormatter
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
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
-
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
andBinaryFormatter
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
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
-
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
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 theBinaryFormatter
, 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