(read-line) non blocking

Started by ale870, December 06, 2008, 07:14:41 AM

Previous topic - Next topic

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

#1
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

#2
Ok! (I will ask around).
--

fred

#3
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

#4
Did you use "ReadPipe" as real argument?

Or... how did you take the handle to the pipe (stdio?) ?
--

ale870

#5
*bump*
--

m35

#6
http://www.google.com/search?q=windows+blocking+stdin">This url led me to http://www.gamedev.net/community/forums/topic.asp?topic_id=285863">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

#7
I really appreciate your suggestion. Thank you for your help!

I will investigate on google ;-)
--