Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to socket within Application (detect disconnects) #914

Open
dbeacham opened this issue Sep 29, 2022 · 1 comment
Open

Access to socket within Application (detect disconnects) #914

dbeacham opened this issue Sep 29, 2022 · 1 comment

Comments

@dbeacham
Copy link

dbeacham commented Sep 29, 2022

We want eagerly detect client disconnections, i.e. before we try to write our response, from our API. Requests can be long running/CPU intensive and don't want to waste cycles unnecessarily.

From this comment in #196 I can see that we could implement the logic ourselves by polling recvBufMsg with MSG_PEEK flag. We could then throw an exception to the thread serving the disconnected client's request.

However, I can't see a way to link the ThreadId of the thread running the request with the Socket that was created when the client connection was accepted. Is there an easy way?

We do have access to SockAddr but I've no idea if that would be unique per live connection.

@nh2
Copy link

nh2 commented Apr 23, 2023

I posted an update on how other web servers do this here: #196 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants