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 9019589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:48:56+00:00 2026-06-16T04:48:56+00:00

So I’ve been getting this exception for about a week now, and I’ve finally

  • 0

So I’ve been getting this exception for about a week now, and I’ve finally managed to corner it into a code snippet that can be easily read.

As a background, I am programming an app for Windows RT and I am trying to use basic sockets.

For the sake of testing, I’ve created a local socket listener to act as a server. Both the server and client need to be able to read/write on the socket.

Neither the client nor the server can (or should) know how much data will come across the wire (if any). This is an absolute requirement. The server should be able to process an arbitrary amount of data on demand.

Here is an example. It is presented as a Unit Test, simply because that is where I consistently encounter the error. Removing any single line from this example causes the error to go away:

    [TestMethod]
    public async Task TestSomething()
    {
        //  Setup local server
        //
        StreamSocketListener listener = new StreamSocketListener();
        listener.ConnectionReceived += async (sender, args) =>
        {
            DataReader serverReader = new DataReader(args.Socket.InputStream);
            await serverReader.LoadAsync(4096);   //  <-- Exception on this line
        };

        await listener.BindServiceNameAsync("10181");

        //  Setup client
        //
        using (StreamSocket socket = new StreamSocket())
        {
            await socket.ConnectAsync(new HostName("localhost"), "10181");

            DataReader reader = new DataReader(socket.InputStream);
            Task readTask = Listen(reader);
        }
    }

    public async Task Listen(DataReader reader)
    {
        await reader.LoadAsync(4096);
    }

The exception happens on the line where the server calls LoadAsync(...), and the exception is thrown when the unit test quits.

The exception is (seemingly) simple:

An existing connection was forcibly closed by the remote host.
(Exception from HRESULT: 0x80072746)

Any clues would be greatly appreciated.

  • 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-06-16T04:48:57+00:00Added an answer on June 16, 2026 at 4:48 am

    With the new WinRT socket types, it’s easier than ever to program sockets correctly, but make no mistake: they are still complex beasts.

    The “forcibly closed” (WSAECONNRESET / 10054) error is when the remote side (in this case, the client) aborts its connection, which it does by disposing its StreamSocket. This is reported as an error but is not uncommon and should be handled gracefully. I.e., if the server has sent all its data and is just waiting to receive more (optional) data, then it should treat WSAECONNRESET as a regular close.

    Tip: If you pass Exception.HResult to SocketError.GetStatus, you should see it’s SocketErrorStatus.ConnectionResetByPeer. That way you can avoid magic values in your error handling code.

    P.S. I have a blog post describing some of the more common socket errors and socket error handling in general.

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you

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.