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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:55:10+00:00 2026-05-10T16:55:10+00:00

I have a class that encapsulates tcp socket communications with a server. For each

  • 0

I have a class that encapsulates tcp socket communications with a server. For each command message sent to the server, the server will send back a response message that invariably contains a response code (OK, Fail). Using my class, each command can be executed either sync or async.

There are basically two types of exceptions that can take place: A ‘fault’ that is caused by a disconnect or some other non-recoverable error and an unexpected exception like ‘send buffer is full’. In the event of a fault, no command can continue or try again or anything until the connection is re-established. In the event of a fail response or even an exception, the command can be tried again…

So, right now my sync command methods return an enum that can have the following values: OK, Fail, Fault. If an exception occurs, it is simply raised to the calling thread (in a sync command). For async commands, the Result property enum value can contain an extra value: OK, Fail, Fault or Exception and the callback can access the actual exception object via the command object’s Exception property.

What do you think about this strategy? I am tempted to not raise exceptions at all for sync commands and just log the exception internally and return the 4th enum value instead because that’s all I’ll really do with exceptions in any given case anyway… Or, should I not be using result codes at all and just raise exceptions in all cases, even faults?

Thanks.

  • 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-10T16:55:10+00:00Added an answer on May 10, 2026 at 4:55 pm

    I think your strategy is basically sound.

    Keep in mind that the purpose of Exceptions is to deal with exceptional conditions. The closer to the source of the problem, the better.

    In your case, it appears that your strategy is something like ‘It didn’t work right now. Let’s retry’. I don’t see a reason to really raise exceptions.

    If dealing with a closed socket was something that required a totally different flow in your code, then maybe exceptions would make sense. From your description, that’s not really the case.

    My philosophy on Exceptions is that they should be for exceptional conditions that you can’t really deal with. A closed socket? Hmm…how many times does the internet go down at my house…

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

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Symbol file incompatibility It's possible that your symbol file (.pdb)… May 11, 2026 at 11:54 am
  • added an answer Please, see the page for the answer. May 11, 2026 at 11:54 am
  • added an answer Personally I really like immutable types. I would write p.plus(q)… May 11, 2026 at 11:54 am

Related Questions

I have a class that encapsulates tcp socket communications with a server. For each
I have a class that I want to use to store properties for another
I have a class that map objects to objects, but unlike dictionary it maps
I have a class that I wish to expose as a remote service using
I have a class that looks like this public class SomeClass { public SomeChildClass[]
I have a class that creates several IDisposable objects, all of these objects are
I have a class that processes a 2 xml files and produces a text
I have a class that utilizes a directory swap method for the Environment.CurrentDirectory. The
I have a class that has a Generic type G In my class model
I have a class that defines the names of various session attributes, e.g. class

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.