From: Martin Sustrik <sustrik@250bpm.com>
To: netdev@vger.kernel.org
Subject: Checking for closed TCP connection in kernel space
Date: Tue, 04 Jan 2011 16:16:43 +0100 [thread overview]
Message-ID: <4D2339DB.2090603@250bpm.com> (raw)
Hi all,
I open a TCP socket in the kernel space (sock_create_kern). I connect or
bind it, I send and receive data. Everything works as expected.
The problem is how to find out that the peer have closed the connection.
In user space you get 0 when calling recv() is such case. However, in
kernel space kernel_recvmsg seems to return 0 anytime when there are no
more data available. It doesn't return an error either.
Should I monitor the socket state using sk_state_change callback? But
the callback seems to work in async manner, i.e. I can accidentally use
closed socket before I get notified about the state change.
Any ideas?
Martin
reply other threads:[~2011-01-04 15:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D2339DB.2090603@250bpm.com \
--to=sustrik@250bpm.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.