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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:45:50+00:00 2026-05-21T02:45:50+00:00

In a client server application a client is connected to server, now if client

  • 0

In a client server application a client is connected to server, now if client disconnects then I want it must trigger an event on the server notifing that it is disconnected. I can achieve this using timer or some loop and a different thread. This thread continuously checks the connection of the client. That is it. But it is something like a polling mechanism. I want to write something like interrupt mechanism. I mean I don’t want to use timer or loop. When a client disconnects willingly or unwillingly either from client side or server side my server should notify that client is disconnected. Please dont tell about how to make custom events.

(I have asked the same question few minutes ago but could not find the response properly and question is closed by the forum…)

  • 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-21T02:45:50+00:00Added an answer on May 21, 2026 at 2:45 am

    It’s not clear whether you’re talking about ASP.NET (or other web stuff), using sockets for direct communication, remoting, WCF or something else. Please clarify if you can.

    It seems you’re talking about polling vs. event-driven systems. The exact implementation and details depend on the question above. “Please dont tell about how to make custom events” doesn’t make much sense: you don’t seem to want to poll and depending on the situation, you might have to create a custom event.


    Update given the fact you’re working with sockets:

    There are no events that are fired, with sockets it will simply be that a read, write, etc call will fail with a SocketException.

    Please see here for more information:

    Instantly detect client disconnection from server socket

    You could create your own event for this, if your socket is handled in another thread for example, your thread method could look something like this:

    bool running = true;
    while (running)
    {
        try
        {
            // do socket work here - read/write/etc
        }
        catch (SocketException)
        {
            // something happened, e.g. client disconnected. stop thread running.
            // you could fire your 'Disconnected' event here.
            running = false;
        }
    }
    

    Basically, when a client disconnects socket methods will throw SocketException, and you can check the SocketError property of the exception object for the reason. It will be one of these:

    http://msdn.microsoft.com/en-us/library/system.net.sockets.socketerror.aspx

    These results indicate a disconnected client: ConnectionReset, NotConnected … but you’ll pretty much have to write-off the whole socket if you get any SocketException.

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

Sidebar

Related Questions

I have a client/server application that communicates with .Net remoting. I need my clients
I have a client server application that sends XML over TCP/IP from client to
I have a client-server application that uses .net remoting. The clients are in a
I have a Server application with a GUI. Written in c#. Now I want
I want to create a remote webservice for an application that is now avaliable
We have a client/server application with a rich client front end (in .Net) and
Is Oracle Application Express suitable for Intranet client/server application? If so, what should I
I have a client/server application. One of the clients is a CLI. The CLI
I have a client-server application written in Java using CORBA for the communication. The
I start to write a client - server application using .net (C#) for both

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.