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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:54:57+00:00 2026-06-09T18:54:57+00:00

I have an application written in C++/CLI that uses a library written in C#.

  • 0

I have an application written in C++/CLI that uses a library written in C#. The application was written using standard socket APIs and uses select() to multiplex a bunch of ordinary non-async sockets. However, the third party library uses .NET sockets and uses the asynchronous results and callbacks.

Here’s the scenario: I create a bunch of regular sockets in the main thread (a C++/CLI application that uses mostly native-style code). I create the third party library vendor’s C# “session” object which, internally, has a bunch of asynchronous sockets from the .NET classes.

What I noticed was that if I put a NULL timeout parameter into select() in the main thread in which I instantiate the C# “session” object, that no asynchronous callbacks are made at all for their .NET sockets. If I use a time-out of, say, 1-second, and no other activity happens on my non-async sockets, then no async-socket callbacks are delivered until select() times out.

Somehow, select() is preventing the callbacks to happen for the .NET sockets. How do I avoid this? Is there some alternative polling method I can use for the old sockets that would still allow the .NET sockets to have their asynchronous callbacks delivered?

  • 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-09T18:54:58+00:00Added an answer on June 9, 2026 at 6:54 pm

    I found the solution.

    In AsyncCallbacks used in .NET, you cannot have any functions that block at all, including send()/recv() functions — even if they are non-blocking[1] (at least according to my own tests.) When a blocking function is called in an AsyncCallback, the behavior is undefined. Once I got rid of this “undefinedness” from the code, things started working as normal.

    I re-templatized my classes by writing some policy classes that swapped out select() for WaitForMultipleObjectsEx() and solved the issue by putting a SetEvent() in the AsyncCallback to trigger the multiplexing. This seemed to solve most of the issues.

    [1] Edit: See below comment. Whether I used send() on a non-blocking or blocking socket didn’t seem to make a difference with regards to “breaking things” and going into undefined behaviors.

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

Sidebar

Related Questions

I have an application written using C++ Builder 5 that uses the TDocument class.
I have an application written in MVC that uses your regular .Net Forms Authentication.
I have application written in Java that is using EJB3 + Toplink. I'm using
I have an application written in C# that uses Outlook Interop to open a
I have an application written in HTML5 that uses localstorage. The user should be
I have an application written in Delphi 6 that uses the Indy 9.0.18 HTTP
I have web application written in java using Eclipse. It has just one servlet
I have an application written in a language called magic. This application uses MSSQL
I have an application written in C# that invokes some C code as well.
I have application written in C#. Memory usage shows that there is a memory

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.