I wrote a socket server running on Linux, but it is probably not linux specificix.
I use poll()to check the status of clients. After sending the request, my clients make an active (half) close. The server is constantly receiving POLLHUPand POLLERRdue to client closure. I also see POLLRDHUP, so I know that in fact half is closed, and the / reset connection is not closed. My problem is that I always get these events, although I already knew from a previous survey that I was half-closed.
poll()
POLLHUP
POLLERR
POLLRDHUP
How can I disable this so that I no longer receive this event? I tried to do extra read()and do shutdown(fd, SHUT_RD), but it doesn't seem to help. I do not want to pollwake up for an event that I have already processed.
read()
shutdown(fd, SHUT_RD)
poll
Stop, including fd in readfds, set as soon as you get half closure. There was nothing left to read except half-closed. From now on, you may only be interested in events that are writable.
Just ignore the POLLHUPreturn flags. Existing code, if correct, will do what you want.
, poll() ( EJP-), , . , ; , , ( TCP-).
"" , poll() . poll() read() , , close(). POLLHUP .
close()
, , POLLHUP. ( ) (.. read()), poll(), "", (). , ( , POLLHUP), .
Source: https://habr.com/ru/post/1528801/More articles:What is the correct method to destroy jqGrid to avoid detaching DOM nodes? - jqgridDoes GNU cpp consider the odd C99 standard for macros null arguments? - ccss3 animation brand does not work automatically - html5Опрос() на именованной трубе возвращается с POLLHUP постоянно и сразу - cJava converts XML to JSON and determines if an array or object will be - javaFractal drawing circles - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1528803/drupal-7-add-headings-to-each-grouped-section-in-my-content-type&usg=ALkJrhjcNnTEdX-px-M-UqiYESpgDse2oQPython full order nested dict - pythonjavascript scope offset - javascriptGive the parent div the width of its floating content - htmlAll Articles