(read-line) non blocking

Notices and updates
Locked
ale870
Posts: 297
Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy

(read-line) non blocking

Post by ale870 »

Hello,

in my program I use (read-line) to read data coming from pipe (I use newlisp -c).

My problem is (read-line) blocks the program until something is found.
Instead I need to check the pipe, and read data only if exist. If no line exist, I need to continue the program.

How can I do it? (Can I get current pipe length for example?)

Thank you!
--

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

On Mac OS X, Linux and other Unix you can use the 'peek' function. On the Win32 version of newLISP this function is not available. Perhaps there exists a similar function in the Win32 SDK which you could import. If you find one let me know.

ale870
Posts: 297
Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy

Post by ale870 »

Ok! (I will ask around).
--

fred
Posts: 8
Joined: Wed Oct 15, 2008 2:24 pm

Post by fred »

You could try GetFileSizeEx which retrieves the size of the specified file.
I used it in: "while GetFileSizeEx(ReadPipe, @size) and (size > 0) do" (Delphi).

ale870
Posts: 297
Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy

Post by ale870 »

Did you use "ReadPipe" as real argument?
Or... how did you take the handle to the pipe (stdio?) ?
--

ale870
Posts: 297
Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy

Post by ale870 »

*bump*
--

m35
Posts: 171
Joined: Wed Feb 14, 2007 12:54 pm

Post by m35 »

This url led me to this promising thread ;)

I once tried playing with Windows stream read blocking and IPC in newLISP, but eventually changed my approach and language for various reasons.

You will probably have to utilize Win32 API functions, but I can't help beyond that. I haven't seen much discussion of Win32 API use on this board, so you might have better luck asking Google or Win32 API specific boards for help.

ale870
Posts: 297
Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy

Post by ale870 »

I really appreciate your suggestion. Thank you for your help!
I will investigate on google ;-)
--

Locked