Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wrote my own server with epoll. When I sent TCP keep alive packages from client to server, epoll event will not get triggered. Question: I want my server to keep the connection open when server gets tcp keep alive packages.

I also tried to look at tcp info but there are no update for its attributes when server got keep alive packages.

I understand tcp keep alive packages is no data but header. I saw in my tcpdump, kernel sent back tcp keep alive ACK after received keep alive package. My goal is to keep connection open when keep alive arrives (kind like reset timer in my server, my server can close connection in no tcp real data)

I set up my client to make connection and send data (e.g "hello world") then send keep alive packages to server.

My server is epoll triggered. I already also tried to set my server to be non-blocking.

// epoll setting I tested
EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLET

(most questions I found on internet are related to client side, my question is more towards server or receiver side of tcp keep alive, how to keep it open)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
213 views
Welcome To Ask or Share your Answers For Others

1 Answer

No, this is not possible as far as I know.

You will have to implement a heartbeat in the application protocol, and then you can stop using TCP keepalive.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...