Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6141179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:12:52+00:00 2026-05-23T18:12:52+00:00

Ok here is my problem. I am trying to take a screenshot, add it

  • 0

Ok here is my problem.
I am trying to take a screenshot, add it to an xmldocument, send it over a socket, and read it with a XmlReader.

Here’s some code…

Server Side

private void SendRandomData(object data)
{
    XMLShitSock sock = data as XMLShitSock;
    if(sock != null)
    {
        int incnum = 0;
        while(sock.Connected)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            doc.AppendChild(docNode);

            XmlNode productsNode = doc.CreateElement("image");

            productsNode.InnerText = Convert.ToBase64String(Program.CaptureImageToBytes(new Point(0, 0), new Rectangle(0, 0, Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height), ImageFormat.Png));
            doc.AppendChild(productsNode);
            string s = XMLShitSock.GetXmlString(doc);
            doc.Save("temp.xml");
            sock.WriteXMLMessage(doc);
            incnum++;
            Thread.Sleep(5000);
        }
    }
}

sock.WriteXMLMessage

public bool WriteXMLMessage(XmlDocument doc)
{
    try
    {
        ShittySocket.Client.Send(Encoding.ASCII.GetBytes(GetXmlString(doc)));
        return true;
    }
    catch(SocketException se)
    {
        this.Close();
        return false;
    }
}

To Read input

private void doInput()
{
    MemoryStream ms = new MemoryStream();
    NetworkStream ns = new NetworkStream(ShittySocket.Client, false);
    while(_connected)
    {
        if(ns.DataAvailable)
        {
            StreamReader sr = new StreamReader(ns);
            char[] b = new char[512];
            int nread = sr.Read(b, 0, 512);

            ms.Write(System.Text.Encoding.ASCII.GetBytes(b, 0, nread), 0, nread);
            ms.Seek(0, System.IO.SeekOrigin.Begin);

            XmlReaderSettings xrs = new XmlReaderSettings();

            XmlReader reader = XmlReader.Create(ms);
            if(reader.Read())
            {
                XmlDocument objXmlDocument = new XmlDocument();
                objXmlDocument.Load(reader);
                onInput(this, objXmlDocument);
                ms.Close();
                ms = new MemoryStream();
            }
        }
        Thread.Sleep(100);
    }
}

Problem I’m having is I get an error in doInput() saying the end of the document was reached without find the tag. I saved the xml file and looked through it and it exists, and I didn’t even find any < characters besides those in the actual tags, so I’m not sure what’s going on here. I’m obviously missing something.

Also, if you have concerns with the semantics or coding style, or anything that doesn’t actually answer the question, please leave it as a comment, since it’s not an answer.

Also
I’ve look through this ->> http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader.readbase64.aspx and I’m hoping that there is a better way to deal with base64 data than separating it from the XMLDocument itself. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:12:53+00:00Added an answer on May 23, 2026 at 6:12 pm

    It looks like you’re assuming the entire data will be read in one 512-byte chunk. Therefore, if the actual data is, say, 513 bytes long then you won’t get the closing angle bracket > at the end of the document, thus the XML parser fails.

    I don’t know exactly what type of network stream you’re using but if it’s plain vanilla sockets then you need some kind of delimiter to know when you’ve reached the end of one “send” and the start of the next, because vanilla sockets are just a pipeline of data. With one read you could be receiving half, one, two, three-and-a-bit actual blocks.

    Handily, you have a delimiter in the form of the closing tag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve the problem here but I don't know why my code
I'm trying to parse some css files using a code project parser found here
I'm having a real problem here. Take this code: Get-WmiObject Win32_ComputerSystemProduct -ComputerName summer |
Here is a problem I am trying to solve: I have an irregular shape.
Here's my problem - I'm trying to access a session namespace across actions .
Here's my problem: I'm trying to set up a simple mobile contact form with
I have an interesting problem here I've been trying to solve for the last
I am stuck with a small problem here.. What i am trying to do
I'm having a hard time trying to create a XmlRepository. The problem here I
Here's my problem. I'm currently trying to develop a .Net Compact Framework 2.0 application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.