Page 1 of 1
(read-line) non blocking
Posted: Sat Dec 06, 2008 3:14 pm
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!
Posted: Sat Dec 06, 2008 5:02 pm
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.
Posted: Sat Dec 06, 2008 5:37 pm
by ale870
Ok! (I will ask around).
Posted: Tue Dec 09, 2008 7:41 am
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).
Posted: Tue Dec 09, 2008 8:55 am
by ale870
Did you use "ReadPipe" as real argument?
Or... how did you take the handle to the pipe (stdio?) ?
Posted: Wed Dec 10, 2008 7:31 am
by ale870
*bump*
Posted: Wed Dec 10, 2008 9:51 pm
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.
Posted: Wed Dec 10, 2008 9:54 pm
by ale870
I really appreciate your suggestion. Thank you for your help!
I will investigate on google ;-)