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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:12:03+00:00 2026-05-11T08:12:03+00:00

A few words about an ongoing design and implementation I send a lot of

  • 0

A few words about an ongoing design and implementation

I send a lot of requests to the remote application (running on a different host, of course), and the application send back data.

About client

Client is a UI that spawn a separate thread to submit and process the requests. Once it submits all the requests, it calls Wait. And the Wait will parse all events coming the app and invoke client’s callbacks.

Below is the implementation of Wait.

public void Wait (uint milliseconds) {        while(_socket.IsConnected)        {          if (_socket.Poll(milliseconds, SelectMode.SelectRead))          {               // read info of the buffer and calls registered callbacks for the client               if(_socket.IsAvailable > 0)                     ProcessSocket(socket);          }          else             return; //returns after Poll has expired       } } 

The Wait is called from a separate thread, responsible for managing network connection: both inbound and outbound traffic:

         _Receiver = new Thread(DoWork);          _Receiver.IsBackground = true;          _Receiver.Start(this); 

This thread is created from UI component of the application.

The issue:

client sometimes sees delays in callbacks even though main application has sent the data on time. Notably, one the message in Poll was delayed until I client disconnected, and internally I called:

_socket.Shutdown(SocketShutdown.Both); 

I think something funky is happening in the Poll

Any suggestions on how to fix the issue or an alternative workaround?

Thanks

please let me know if anything is unclear

  • 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. 2026-05-11T08:12:03+00:00Added an answer on May 11, 2026 at 8:12 am

    A couple of things. First, in your example, is there a difference between ‘_socket’ and ‘socket’? Second, you are using the System.Net.Sockets.Socket class, right? I don’t see IsConnected or IsAvailable properties on that class in the MSDN documentation for any .NET version going back to 1.1. I assume these are both typing mistakes, right?

    Have you tried putting an ‘else’ clause on the ‘IsAvailable > 0’ test and writing a message to the Console/Output window, e.g.,

      if (_socket.IsAvailable > 0) {       ProcessSocket(socket);   } else {       Console.WriteLine('Poll() returned true but there is no data');   } 

    This might give you an idea of what might be going on in the larger context of your program.

    Aside from that, I’m not a big fan of polling sockets for data. As an alternative, is there a reason not to use the asynchronous Begin/EndReceive functions on the socket? I think it’d be straightforward to convert to the asynchronous model given the fact that you’re already using a separate thread to send and receive your data. Here is an example from MSDN. Additionally, I’ve added the typical implementation that I use of this mechanism to this SO post.

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

Sidebar

Related Questions

few days ago i asked about how to get all running processes in the
I've got to write few words about C#, generally piece of cake? No! I've
I'm having some issues with removing some HTML elements. Just a few words about
I am building a application with on WM6.1, few question about the resource control.
In few words, is it correct way to call keydown and keyup events, that
It is not a programming question, but need your views in few words. When
I'd like to brush my brain to avoid confusions. In few words, what can
Very quick question - if I deploy a WPF application to a few users,
I am developing an iphone app where users input a few words and I
Has anyone used the Highcharts Javascript charting library? I have a few questions about

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.