I am developing a LAN messenger in c# using sockets, i want to use XML for entire communication, can you people help me? or give me some link or code snippet?
any help will be appreciated
thanks in advance

6 Years
Discussion Span
Last Post by Ketsuekiame

You say you want to use XML for communication? In what sense? What you send over the socket needs to be converted into bytes. So build your XML in memory, then convert that into a byte array and send it over your socket and rebuild it at the other end.

There is no function to send XML over a socket.

An alternative is to use WCF. Lots of information about WCF can be found in the MSDN


@ Ketsuekiame
the requirement given to me is:-

You're required to implement a LAN Messenger software:-

Feature List
- Chat with One or Multiple Friends at a time.
- Notification Icon of application in System Tray.
- Popup window when a friend signs in.

- Entire communication shall be done using XML.
- Each message will be verified using DTD.


To transmit the data over the network, you still need to break it down into bytes. But the message you send can be in XML.

I imagine you will be running a server, which communicates with all the clients? If not, that's going to be rather difficult to implement ^^


@ Ketsuekiame
yes you are right brother, server will communicate with all clients, and the message will be broken in bytes, but i want to use XML to transmit these bytes to clients. :-)


Well if you need to use XML as your "message" then how about something like this as your markup...

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <Data>Whatever the message is here</Data>

Obviously you would need a DTD that also matches this and the DTD should cover a message that is either from a client or a server. This is just to give you an idea.

Once you have the XML, you can serialise it into a byte stream fairly easily. Look into the BinaryFormatter

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.