newLISP Fan Club

Forum => newLISP newS => Topic started by: ale870 on December 06, 2008, 07:14:41 AM

Title: (read-line) non blocking
Post by: ale870 on December 06, 2008, 07:14:41 AM
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!
Title:
Post by: Lutz on December 06, 2008, 09:02:29 AM
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.
Title:
Post by: ale870 on December 06, 2008, 09:37:17 AM
Ok! (I will ask around).
Title:
Post by: fred on December 08, 2008, 11:41:03 PM
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).
Title:
Post by: ale870 on December 09, 2008, 12:55:29 AM
Did you use "ReadPipe" as real argument?

Or... how did you take the handle to the pipe (stdio?) ?
Title:
Post by: ale870 on December 09, 2008, 11:31:15 PM
*bump*
Title:
Post by: m35 on December 10, 2008, 01:51:08 PM
This (//http) url led me to this promising thread (//http) ;)



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.
Title:
Post by: ale870 on December 10, 2008, 01:54:57 PM
I really appreciate your suggestion. Thank you for your help!

I will investigate on google ;-)