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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:44:53+00:00 2026-05-13T17:44:53+00:00

Another socket problem. In my client code, I am sending some packet and expectign

  • 0

Another socket problem.

In my client code, I am sending some packet and expectign some response from the server side:


send()

recv() <– it is blocking

Immediately after send(), the server crashes and rebooted itself. In the meantime the recv() is waiting. But even after the server is up, the receive call is hanging. I have added SIGPIPE signal handling but its still not able to recognize that the socket is broken.

When i cancel the operation, i got the error from recv() that interrupt has been issued.

Anyone could help me how to rectify this error?

This is in a shared library running on Solaris machine.

  • 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-13T17:44:53+00:00Added an answer on May 13, 2026 at 5:44 pm

    As others have mentioned, you can use select() to set a time limit for the socket to become readable.

    By default, the socket will become readable when there’s one or more bytes available in the socket receive buffer. I say “by default” because this amount is tunable by setting the socket receive buffer “low water mark” using the SO_RCVLOWAT socket option.

    Below is a function you can use to determine if the socket is ready to be read within a specified time limit. It will return 1 if the socket has data available for reading. Otherwise, it will return 0 if it times out.

    The code is based on an example from the book Unix Network Programming (www.unpbook.com) that can provide you with more information.

    /* Wait for "timeout" seconds for the socket to become readable */
    readable_timeout(int sock, int timeout)
    {
        struct timeval tv;
        fd_set         rset;
        int            isready;
    
        FD_ZERO(&rset);
        FD_SET(sock, &rset);
    
        tv.tv_sec  = timeout;
        tv.tv_usec = 0;
    
     again:
        isready = select(sock+1, &rset, NULL, NULL, &tv);
        if (isready < 0) {
            if (errno == EINTR) goto again;
            perror("select"); _exit(1);
        }
    
        return isready;
    }
    

    Use it like this:

    if (readable_timeout(sock, 5/*timeout*/)) {
        recv(sock, ...)
    

    You mention handling SIGPIPE on the client side which is separate issue. If you are getting this is means your client is writing to the socket, even after having received a RST from the server. That is a separate issue from having a problem with a blocking call to recv().

    The way that could arise is that the server crashes and reboots, losing its TCP state. Your client sends data to the server which sends back a RST, since it no longer has state for the connection. Your client ignores the RST and tries to send more data and it’s this second send() which causes your program to receive the SIGPIPE signal.

    What error were you getting from the call to recv()?

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Call Path.GetFullPath; it will throw exceptions if the path is… May 15, 2026 at 1:41 pm
  • Editorial Team
    Editorial Team added an answer The response code is only going to be set if… May 15, 2026 at 1:41 pm
  • Editorial Team
    Editorial Team added an answer FROM CREATOR OF QtWorkBench: Comment 12 by y.pagles, Jun 11,… May 15, 2026 at 1:41 pm

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.