[fpc-pascal]How to get read-timeouts when reading sockets?

Thomas Schatzl tom_at_work at yline.com
Fri Jun 8 10:51:04 CEST 2001


Hi!

>I took the finger-sourcecode, but I got the problem, that I couldn't
>determine if there were any data left to read. The eof seems to occur
>only when the socket is closed?
>
>Additionally it seems important to me that there is a timeout when
>waiting for data just because otherwise a non-standard answer could
>block this program.

You might try to have a look at the select() call. I think it meets your
requirements. Additionally you could create an exclusive thread for the
network stuff.
Or set your socket to nonblocking mode via ioctl() (I guess you're
programming with Linux ??) and poll for data in a loop (not recommened
though since it hogs the cpu).

Regards,
    Thomas





More information about the fpc-pascal mailing list