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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:09:39+00:00 2026-05-12T00:09:39+00:00

Suppose that there’re two types of packet in the chatting server. Those two packets

  • 0

Suppose that there’re two types of packet in the chatting server. Those two packets are used for getting the status of another user. One(call this as REQ-STAT, RES-STAT) is request-and-response form and another one(NOT-STAT) is notification form packet.

For instance, if I send [REQ-STAT simpson] to the server and I may get [RES-STAT simpson online]. Or, if the user SIMPSON’s status has been changed, I’ll get the user’s status like [NOT-STAT simpson offline].

Okay, the server is running on multi-core machine and using multiple threads, of course.

If the server get [REQ-STAT simpson] packet, the server will prepare packet [RES-STAT simpson online] – if the SIMPSON is online. At this point, the SIMPSON logged out, so the server send packet [NOT-STAT simpson offline] to the client. After the server sent [NOT-STAT simpson offline] packet, [RES-STAT simpson online] packet is sent

// the server lock during using user data structure but not for the whole process.

------[REQ-STAT simpson]------> simpson is online and prepare response packet

<--[NOT-STAT simpson offline]-- simpson has been logged out and send not packet

<--[RES-STAT simpson online]--- send response

// the latest packet does not have the latest information !!!

Can above scenario be happen if LOCK does not used for whole process? If so, do I should lock that all? Any other solutions?

Thanks.

  • 1 1 Answer
  • 1 View
  • 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-12T00:09:39+00:00Added an answer on May 12, 2026 at 12:09 am

    Well it appears that you can solve it by the way the receiving program treats the different packets.

    If the program asks if SIMPSON is online, it expects an answer of yes or no. But it should treat that as: SIMPSON was or was not online around the time I sent my request but he could have logged out 1 millisecond after this packet was created so I’m not guaranteed he’s online now, I just know he was when I asked. Use this information for what it’s worth.

    However, when the program receives a “SIMPSON signed off” packet, then you know that SIMPSON signed off at the time specified in the packet. Receiving this would override any pending request for current status because you were just told that he signed off. So “abort” the current status request if there is one. By abort I mean gracefully stop that thread or ignore the result for that request.

    Another option is to embed a high-resolution time stamp (which must be thread-safe) or a thread-safe, client-specific sequential counter into every packet so the client can figure out the order of events independent of the order of receiving them. Standard thread-safe programming practices will allow you to do this and it sounds like you’re knowledgeable about that.

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

Sidebar

Related Questions

Suppose that there are 3 databases for Production Staging Dev As far as I
I suppose there could be historical reasons for this naming and that other languages
Suppose I have: Toby Tiny Tory Tily Is there an algorithm that can easily
Suppose I have a table called Companies that has a DepartmentID column. There's also
Suppose I have a SELECT statement that returns some set of results. Is there
Is there any Visual Studio Add-In that can do the remove method refactoring? Suppose
In the vein of programming questions : suppose there's a collection of objects that
Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable;
example: hello+all.domain.com works with chrome/firefox. it does not with ie/safari. I suppose that there
suppose that there is given following matlab code function dp = derp(p) n =

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.