Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-06

How to get read-timeouts when reading sockets?

7 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Vogel

Hi!

Yesterday evening I tried to build a little telnet-program, just to test the IP-socket-implementation.

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.

Tschau!

Michael

"Macht's gut und danke für den Fisch" Sig geändert zum Gedenken an Douglas Adams (1952 - 11.05.2001) http://www.douglasadams.com/

Reply by email

Peter Vreman
Show quoted text 12 lines
Hi! Yesterday evening I tried to build a little telnet-program, just to test the IP-socket-implementation. 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 need to use select()

Reply by email

Mirek Novak
to Michael Vogel: Hi! Yesterday evening I tried to build a little telnet-program, just to test the…

On both platforms (Linux/Win) u have to use Select (see FPC manual Reference Guide for linux platform)

Mirek Novak

Michael Vogel píše:

Show quoted text 24 lines
Hi! Yesterday evening I tried to build a little telnet-program, just to test the IP-socket-implementation. 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. Tschau! Michael -- "Macht's gut und danke für den Fisch" Sig geändert zum Gedenken an Douglas Adams (1952 - 11.05.2001) http://www.douglasadams.com/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Thomas Schatzl
to Michael Vogel: Hi! Yesterday evening I tried to build a little telnet-program, just to test the…

Hi!

Show quoted text 7 lines
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

Reply by email

Michael Vogel

Hi!

"Thomas Schatzl" wrote
You might try to have a look at the select() call.

At home I will take a 's in the crt-unit, isn't it? Yesterday I haven't found any function that could help me ...

Or set your socket to nonblocking mode via ioctl() (I guess you're programming with Linux ??)

Yeah. Sorry, I hadn't mentioned that.

and poll for data in a loop (not recommened though since it hogs the cpu).

Urgh, no, that's not good.

Tschau!

Michael

"Macht's gut und danke für den Fisch" Sig geändert zum Gedenken an Douglas Adams (1952 - 11.05.2001) http://www.douglasadams.com/

Reply by email

Sebastian Günther
to Michael Vogel
Michael Vogel wrote
>You might try to have a look at the select() call. At home I will take a 's in the crt-unit, isn't it?

no, in the Linux or Unix unit

Additionally, there is a unit called AsyncIO in the FCL, which is some kind of OOP wrapper for select(). The next version, which is currently in testing stage, will be released soon and will also work on Win32.

- Sebastian

Reply by email

Gabor DEAK JAHN
to Sebastian Günther

Hello,

does anybody have some source to handle a tree view control with checkboxes under Win32? The main problem is that Windows doesn't send any good message when the checkbox is checked or cleared. I didn't yet find a rock solid workaround...

Bye,
Gábor

------------------------------------------------------------------- Gabor DEAK JAHN -- Budapest, Hungary.
E-mail:

Reply by email