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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:21:47+00:00 2026-06-12T19:21:47+00:00

I am losing data on my sockets because I am doing a close() .

  • 0

I am losing data on my sockets because I am doing a close().

The Linux-specific shutdown() manpage is not helpful:

The shutdown() call causes all or part of a full-duplex connection on
the socket associated with sockfd to be shut down. If how is SHUT_RD,
further receptions will be disallowed. If how is SHUT_WR, further
transmissions will be disallowed. If how is SHUT_RDWR, further
receptions and transmissions will be disallowed.

Microsoft’s MSDN is MUCH better, but it being Windows specific, there are differences between it and Linux:

To assure that all data is sent and received on a connected socket
before it is closed, an application should use shutdown to close
connection before calling closesocket. One method to wait for
notification that the remote end has sent all its data and initiated a
graceful disconnect uses the WSAEventSelect function as follows :

1. Call WSAEventSelect to register for FD_CLOSE notification.
2. Call shutdown with how=SD_SEND.
3. When FD_CLOSE received, call the recv or WSARecv until the function completes with success and indicates that zero bytes were received. If SOCKET_ERROR is returned, then the graceful disconnect is not possible.
4. Call closesocket.

My Question

  • Under Linux, what is the equivalent of waiting for FD_CLOSE (step 1)?

I am getting answers and comments that think I am asking about the behavior on Windows. I am asking about the behavior on Linux, I am merely referencing the Windows documentation because it is much more clear and complete than Linux manpages.

  • 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-06-12T19:21:49+00:00Added an answer on June 12, 2026 at 7:21 pm

    The MSDN suggestions are followed in my very detailed answer to close() is not closing socket properly. This is essentially the same as Remy Lebeau’s answer here.

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

Sidebar

Related Questions

i'm losing it, what am i doing wrong ? Error 3 The name 'BitmapFrame'
I'm having an issue with PHP losing data in a variable. There is quite
I am trying to remove not null constraint in sql server 2008 without losing
I am having a problem in which I am losing data in an arrayList.
I'm losing data-bind when initiating a printing process, is that possible ? Thats what
I want to change the column positions of my database table without losing data.
One of the major problems with WebSQL is its vulnerability to losing data. Every
For the past few months, we've been losing data to a Delayed Write errors.
I`ve recently read this article about a user losing data on EC2 when dealing
I have created an application which uses a System.Net.Sockets.Socket and reads data asynchronously. Everything

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.