-----Ursprüngliche Nachricht----- Von: dries [mailto:dries@irssystems.nl] Gesendet: Donnerstag, 12. Dezember 2002 23:06 An: 'SuSE Programming English' Betreff: Re: AW: [suse-programming-e] How to check in which state is a socket ?
Kai-Uwe Schmidt wrote :
| > even be able to check errno to see what happened). | | [Kai-Uwe Schmidt] hm, this sounds like an idea, but my tests show
| status=select(iClientConnect+1,NULL,&fs_write,NULL,&timeout) returns 1 | and status=read(iClientConnect,&c,0) returns 0. Even when I do a | system("netstat -an | grep <myport>"); before. The system() shows | nothing after 20 sec where I killed the client-connect. Means IMHO
| the kernel doesnt know anything about the socket anymore. | | But iWritten=send(iClientConnect,"Test",strlen("Test"),0) crashes
| process even without writing a core file. | | No clue how to proceed, sounds like a bug in my eyes. | | Kai-Uwe
Well, imho there should be a kernel routine to see what status your connection is in, but there isn't. I got the read zero - bytes trick from the web somewhere. I myself however use the 'select sees there is data to be read but we read 0 bytes' trick, that works for me. [Kai-Uwe Schmidt] I found out, that my programm works on a 2.2.19 Kernel but crashes on 2.4.19-4GB and 2.4.7-4GB (Slox Distri and SEMS3.1 Distri). On those distributions the select() returns always 1, even when
that that the the socket vanishes from the kernel. Select() returns 0 on a e.g. 2.2.19. Kai-Uwe