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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:45:35+00:00 2026-06-05T09:45:35+00:00

I use epoll to build a server, this is the code where I init

  • 0

I use epoll to build a server, this is the code where I init epoll :

core->fd_epoll = epoll_create(LIMIT_CLIENT);
ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
ev.data.fd = core->socket_main;
epoll_ctl(core->fd_epoll, EPOLL_CTL_ADD, core->socket_main, &ev);
while (1)
{
  nfds = epoll_wait(core->fd_epoll, &ev, 90000, -1);
  ...
}

And when I use it to check if there’s something new on my fds :

for (i = 0; i < nfds; i++)
{
  fd = ev[i].data.fd;
  if (fd == core->socket_main)
    {
      socket_fils = socket_accept(core->socket_main, 0);
      event.data.fd = socket_fils;
      event.events = EPOLLIN | EPOLLET | EPOLLRDHUP;
      xepoll_ctl(core->fd_epoll, EPOLL_CTL_ADD, socket_fils, &event);
      printf("Incoming => FD fils %d\n", socket_fils);
    }
  else
    printf("Event %x\n", ev[i].events);
}

When I use netcat to send a message to the server the bitfield events is equal to 1 (EPOLLIN)
When I send a ctrl+c, netcat quits and my bitfield is equal to 2001 (EPOLLIN and EPOLLRDHUP)
When I send a ctrl+d, netcat doesn’t quit but my bitfield is equal to 2001 too…

After a ctrl+d, my server closes the socket. It’s not normal… A ctrl+d should’nt close the socket and return a different bitfield.

How can I know, in the server, if it’s ctrl+c or ctrl+d ?

Thank you.

  • 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-05T09:45:36+00:00Added an answer on June 5, 2026 at 9:45 am

    ctrl+c and ctrl+d keypresses on the terminal that is running netcat cannot be “seen” directly by your server. They cause, respectively, a SIGINT signal to be sent to netcat, and an EOF condition to be seen by netcat on its stdin. What netcat does with that is really up to netcat, not up to your server. Here’s what they do for me:

    • ctrl+c which sends SIGINT to netcat: netcat is killed because that is the default action of SIGINT, and netcat doesn’t change it. When netcat dies the socket is automatically closed. The server senses this as available incoming data, consistent with the EPOLLIN|EPOLLRDHUP condition you are seeing. If you read the socket, you will find that an EOF is waiting for you.

    • ctrl+d which sends an EOF on netcat’s stdin: netcat noticed the EOF. It will send no further data through the socket. However, it continues running and reading from the socket in case the server has more data to send.

    In other words, I can’t reproduce the netcat behaviour you are seeing (with Linux 2.6 and netcat v1.10-38). Perhaps your version of netcat shuts down the socket for writing after reading an EOF on stdin?

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

Sidebar

Related Questions

I need to create specialized HTTP server, for this I plan to use epoll
use this code, in the Preferences activity, to know when the reset preference has
I would like to use libev for a streaming server I am writing. This
use this website a lot but first time posting. My program creates a number
I'm trying to build a server that will handle many concurrent connections to iPhone
I'm programming an application(client/server) in C++ for linux using epoll y pthreads but I
I'm implementing a Non-Blocking HTTP server in Java and decided to use pure Java
I'm developing a server in C#. This server will act as a data server
I have created a linux server using epoll. And I realized that the clients
Use case: I find a piece of code that I do not understand at

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.