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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:10:16+00:00 2026-05-14T06:10:16+00:00

The following is the setup: Server Client | | accept connect | | v

  • 0

The following is the setup:

Server         Client
 |                |
accept         connect
 |                |
 v                |
send msg1->       | 
 |                |
 v                v
recv    <-     send
 |                |
 v                v
send msg2->    recv
 |                |
 v                v
               close

Here is my question:
1. Client actually receives msg1 before it closes, why is it like this?

2. send msg2 returns normally. Since client closes after receiving msg1, why is send msg2 successful?

P.S. I’m using stream socket for TCP.

  • 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-14T06:10:17+00:00Added an answer on May 14, 2026 at 6:10 am
    1. The recv function will get whatever is next in the receive buffer. In the case of the client, if the socket is a datagram socket, what is next is msg1. If it is a stream socket then message boundaries are not maintained so the recv could include data from both msg1 and msg2 if msg2 has arrived and there is room for both in the recv buffer.

    2. send does not wait for the other side to recv the message, it just adds it to the send queue. It does not know at that point whether the client will close the connection before reading it. If you need to know that you should have the client send a response to acknowledge the message.

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

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • 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
  • Editorial Team
    Editorial Team added an answer Well: txtbox1.Text = ""; should do it. (Note that I… May 16, 2026 at 9:03 am
  • Editorial Team
    Editorial Team added an answer Good question, I was looking into this myself as well.… May 16, 2026 at 9:03 am
  • Editorial Team
    Editorial Team added an answer preg_replace/e or preg_replace_callback is your best bet $vars = array('name'… May 16, 2026 at 9:03 am

Trending Tags

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

Top Members

Related Questions

Here is source code for multithreaed server and client in python. In the code
I am trying to setup a simple UDP client and server using Ruby. The
I've setup-a-msysgit-server-with-copssh-on-windows, following Tim Davis' guide and I was now learning how to use
I am currently developing android XMPP client to communicate with the Tigase server setup
I have a following setup: App - Magnolia site running under Tomcat 6.0.16 ISAPI
I'm trying to install SQL Server 2005 Developer Edition on my Windows 7 Ultimate
I've bumped into a strange problem. I wrote a little daemon in Perl which
I've been learning a lot about web technologies recently and I want to put
Attempting to use JRuby 1.2.0 and Rails 2.3.2 with an embedded Derby database. I've

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.