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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:58:53+00:00 2026-06-05T07:58:53+00:00

I have a multihreaded client-server application. The first thread is a listener which adds

  • 0

I have a multihreaded client-server application. The first thread is a “listener” which adds client to a array of a file descriptors:

while (1) {
    if ((connfd = accept(listenfd_service, (struct sockaddr *) &cliaddr, &clilen)) > 0) {
        printf("service connected...\n");
        int i;
        for (i = 0; i < MAX_SERVICES; i++) {
            if (service_sockets[i] == -1) {
                service_sockets[i] = connfd;
                break;
            }
        }
    }
}

The problem is that when I terminate the client with Ctrl+C and run the following lines

for (j = 0; j < MAX_SERVICES; j++) {
    if (service_sockets[j] != -1) {
        int test = write(service_sockets[j], c, 72);
        if (test == -1) {
            service_sockets[j] = -1;
        }
    }
}

I get a 72 in a ‘test’ variable. If I try to run these lines second time, I get a SIGPIPE signal.

  • 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-05T07:58:54+00:00Added an answer on June 5, 2026 at 7:58 am

    That’s normal and expected behavior. The server won’t find out immediately when the client exits, as normally when there’s no data going over a network connection, there’s no data being transmitted. Instead, the next time the server sends data it will send off a packet (that’s your successful write of 72 bytes), and the client machine (if the OS is still running) will respond with a “Connection Reset” message. This will cause the server OS to close its end of the connection, causing a SIGPIPE/EPIPE when the server next writes to the socket.

    The normal way of dealing with this is to ignore SIGPIPE signals, and handle the write returning an EPIPE error. Pretty much any process which deals with multiple connections and may have one go away while others are still useful needs to ignore SIGPIPEs.

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

Sidebar

Related Questions

I have coded a single threaded client server model which does following: Server loops
I have a multithreaded application in which my thread utilization is very poor (in
I have a client/server application that depends on MS SQL database for backend storage,
Is in multithreaded application suitable to have 1 connection per 1 connected client? To
I have a multithreaded C++ application which holds a complex data structure in memory
I have a server that communicates with a client. The server is multithreaded, and
I have a simple multithreaded C# server and client. When just one client is
I have the following problem: I have a multithreaded server-side application, where every request
I have to write a multithreaded client and server using Java's socket api. Both
I have a server and a client program. The server program runs all the

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.