Hi cinap,
hangup(cfd);/* hangup connection, fd stays valid but i/o will error */
thank you for your explanation and help.
Going to use 'hangup' function. ;)
Pavel
another way to implement these kinds of timeouts is
alarm(), see sleep(2).
--
cinap
another way to implement these kinds of timeouts is
alarm(), see sleep(2).
Yes, I know.
But it was just a simplified example to explain my real need:
- 'receiver' process
- another 'sender' process, which should have a possibility to close the
TCP connection, and relase 'receiver' from read()
ah, ok :)
--
cinap
OTOH, 'hangup' approach does not work in UDP.
It means, read() is not finished... :(
Pavel
2014-11-13 14:17 GMT+01:00 cinap_len...@felloff.net:
ah, ok :)
--
cinap
interesting, that might be worth implementing.
the alternative would be to send the reading process a note to
interrupt the blocking syscall.
the closer proc should just send the note and not close the fd.
and the reader proc should close the fd once he's out of the
reading loop.
--
cinap
interesting, that might be worth implementing.
Maybe.
the alternative would be to send the reading process a note to
interrupt the blocking syscall.
Actually, it my 'plan B'... ;)
the closer proc should just send the note and not close the fd.
and the reader proc should close the fd
the changes to implement udp hangup are trivial tho:
diff -r 51564dc1adae sys/src/9/ip/udp.c
--- a/sys/src/9/ip/udp.cThu Nov 13 10:23:53 2014 +0100
+++ b/sys/src/9/ip/udp.cThu Nov 13 15:42:24 2014 +0100
@@ -518,6 +518,11 @@
ucb = (Udpcb*)c-ptcl;
if(n == 1){
+
the changes to implement udp hangup are trivial tho:
diff -r 51564dc1adae sys/src/9/ip/udp.c
--- a/sys/src/9/ip/udp.cThu Nov 13 10:23:53 2014 +0100
+++ b/sys/src/9/ip/udp.cThu Nov 13 15:42:24 2014 +0100
@@ -518,6 +518,11 @@
ucb = (Udpcb*)c-ptcl;
if(n == 1){
+ if(strcmp(f[0], hangup) == 0){
+ qhangup(c-rq, nil);
+ qhangup(c-wq, nil);
+ return nil;
+ }
You patch works as expected. ;)
Thanks.
Pavel
10 matches
Mail list logo