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

  • Home
  • SEARCH
  • 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 3721892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:42:40+00:00 2026-05-19T05:42:40+00:00

Naturally, BeginReceive() will never end if there’s no data. MSDN suggests that calling Close()

  • 0

Naturally, BeginReceive() will never end if there’s no data.
MSDN suggests that calling Close() would abort BeginReceive().

However, calling Close() on the socket also performs a Dispose() on it, as figured out in this great answer, and consequently EndReceive() would throw an exception because the object is already disposed (and it does!).

How should I proceed?

  • 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-19T05:42:41+00:00Added an answer on May 19, 2026 at 5:42 am

    It seems like this is by (the very dumb) design. You must have this exception thrown and caught in your code.

    MSDN looks silent about it indeed, but if you look at the documentation of another asynchronous socket method, BeginConnect(), here’s what we find:

    To cancel a pending call to the
    BeginConnect() method, close the
    Socket. When the Close() method is
    called while an asynchronous operation
    is in progress, the callback provided
    to the BeginConnect() method is
    called. A subsequent call to the
    EndConnect(IAsyncResult) method will
    throw an ObjectDisposedException to
    indicate that the operation has been
    cancelled.

    If it is the proper way of doing for BeginConnect, it is probably so for BeginReceive as well. This is certainly a poor design on the part of Microsoft’s async API, because making the user necessarily throw and catch exception as a part of a normal flow would annoy the debugger. You have really no way to “wait” until the operation is completed, because Close() is what completes it in the first place.

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

Sidebar

Related Questions

I am constructing a query that will naturally return a result that has values
When developing with .NET 3.5 I naturally use LINQ for data access. But for
I need to add line breaks in the positions that the browser naturally adds
I have a win form UI that looks like a typical calculator. Naturally I
It would seem natural to me that HTML would support this: <div id=comment1> <div
I'm developing a server in C#. This server will act as a data server
Windows 7 windows naturally have a semi-transparent header. What I just realized is that
My data fits a tree form naturally. Therefore, I have a simple SQL table
I currently have an application that naturally gets pushed to the background when the
So I have my first MVC2 site that I'm working on and naturally I'd

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.