Opening Win32 pipe strange behaviour
Hi Lutz!
Well, good news: it works!! See the GTK-server demo program below. With the Borland-binary this program will not run.
But for some strange reason, the (sleep x) function does not work anymore with the MinGW binary, so I simulated a sleep with a large (for) loop.
Anyway, I volunteer to test the MinGW version of newLisp in the next future. If you are OK, I will use it in all my Win32 newLisp programs and submit problems to this forum...? (So one problem already is the 'sleep' function... ;0) )
Thank you for the extremely good and fast support.
Regards
Peter
============================
;------------------------------------------------
;
; Demonstration on how to use the GTK-server with NEWLISP by FIFO.
; Tested with newLISP 8.0.9 compiled with MinGW on WindowsXP.
;
; July 17, 2004 by Pjot.
;
;------------------------------------------------
; Define communication function
(define (gtk str)
(write-buffer pipeout str)
(read-buffer pipein 'tmp 128)
tmp)
; Start the gtk-server
(process "gtk-server fifo log")
(for (x 1 2000000))
; Connect to the GTK-server
(set 'pipeout (open {\\.\pipe\out} "w"))
(println pipeout)
(set 'pipein (open {\\.\pipe\in} "r"))
(println pipein)
; Setup GUI
(gtk "gtk_init(NULL, NULL)")
(set 'win (gtk "gtk_window_new(0)"))
(gtk (append "gtk_window_set_title (" win ", This is a title)"))
(gtk (append "gtk_window_set_default_size (" win ", 100, 100)"))
(gtk (append "gtk_window_set_position (" win ", 1 )"))
(set 'table (gtk "gtk_table_new(30, 30, 1 )"))
(gtk (append "gtk_container_add (" win "," table ")"))
(set 'button1 (gtk "gtk_button_new_with_label (Exit)"))
(gtk (append "gtk_table_attach_defaults(" table ", " button1 ", 17, 28, 20, 25)"))
(set 'button2 (gtk "gtk_button_new_with_label (Print text)"))
(gtk (append "gtk_table_attach_defaults (" table ", " button2 ", 2, 13, 20, 25)"))
(set 'entry (gtk "gtk_entry_new()"))
(gtk (append "gtk_table_attach_defaults (" table ", " entry ", 2, 28, 5, 15)"))
(gtk (append "gtk_widget_show_all(" win ")"))
(gtk (append "gtk_widget_grab_focus(" entry ")"))
; Initialize
(set 'cb1 0)
(set 'cb2 0)
(set 'event 0)
; This is the mainloop
(while (= (integer event) 0)
(gtk "gtk_main_iteration_do(0)")
(set 'cb1 (gtk (append "gtk_server_callback(" button2 ")")))
(set 'cb2 (gtk (append "gtk_server_callback(" entry ")")))
(if (or (= (integer cb1) 1) (= (integer cb2) 1))
(begin
(set 'tmp (gtk (append "gtk_entry_get_text(" entry ")")))
(println tmp)
(gtk (append "gtk_editable_delete_text(" entry ", 0, -1)"))
(gtk (append "gtk_widget_grab_focus(" entry ")"))
))
(set 'event (gtk (append "gtk_server_callback(" button1 ")"))))
(write-buffer pipeout "gtk_exit(0)")
(exit)
Well, good news: it works!! See the GTK-server demo program below. With the Borland-binary this program will not run.
But for some strange reason, the (sleep x) function does not work anymore with the MinGW binary, so I simulated a sleep with a large (for) loop.
Anyway, I volunteer to test the MinGW version of newLisp in the next future. If you are OK, I will use it in all my Win32 newLisp programs and submit problems to this forum...? (So one problem already is the 'sleep' function... ;0) )
Thank you for the extremely good and fast support.
Regards
Peter
============================
;------------------------------------------------
;
; Demonstration on how to use the GTK-server with NEWLISP by FIFO.
; Tested with newLISP 8.0.9 compiled with MinGW on WindowsXP.
;
; July 17, 2004 by Pjot.
;
;------------------------------------------------
; Define communication function
(define (gtk str)
(write-buffer pipeout str)
(read-buffer pipein 'tmp 128)
tmp)
; Start the gtk-server
(process "gtk-server fifo log")
(for (x 1 2000000))
; Connect to the GTK-server
(set 'pipeout (open {\\.\pipe\out} "w"))
(println pipeout)
(set 'pipein (open {\\.\pipe\in} "r"))
(println pipein)
; Setup GUI
(gtk "gtk_init(NULL, NULL)")
(set 'win (gtk "gtk_window_new(0)"))
(gtk (append "gtk_window_set_title (" win ", This is a title)"))
(gtk (append "gtk_window_set_default_size (" win ", 100, 100)"))
(gtk (append "gtk_window_set_position (" win ", 1 )"))
(set 'table (gtk "gtk_table_new(30, 30, 1 )"))
(gtk (append "gtk_container_add (" win "," table ")"))
(set 'button1 (gtk "gtk_button_new_with_label (Exit)"))
(gtk (append "gtk_table_attach_defaults(" table ", " button1 ", 17, 28, 20, 25)"))
(set 'button2 (gtk "gtk_button_new_with_label (Print text)"))
(gtk (append "gtk_table_attach_defaults (" table ", " button2 ", 2, 13, 20, 25)"))
(set 'entry (gtk "gtk_entry_new()"))
(gtk (append "gtk_table_attach_defaults (" table ", " entry ", 2, 28, 5, 15)"))
(gtk (append "gtk_widget_show_all(" win ")"))
(gtk (append "gtk_widget_grab_focus(" entry ")"))
; Initialize
(set 'cb1 0)
(set 'cb2 0)
(set 'event 0)
; This is the mainloop
(while (= (integer event) 0)
(gtk "gtk_main_iteration_do(0)")
(set 'cb1 (gtk (append "gtk_server_callback(" button2 ")")))
(set 'cb2 (gtk (append "gtk_server_callback(" entry ")")))
(if (or (= (integer cb1) 1) (= (integer cb2) 1))
(begin
(set 'tmp (gtk (append "gtk_entry_get_text(" entry ")")))
(println tmp)
(gtk (append "gtk_editable_delete_text(" entry ", 0, -1)"))
(gtk (append "gtk_widget_grab_focus(" entry ")"))
))
(set 'event (gtk (append "gtk_server_callback(" button1 ")"))))
(write-buffer pipeout "gtk_exit(0)")
(exit)
Good News! Turns out I was linking unnecessary libraries. The new version of newlisp-mingw.exe is only 143Kbyte, that is a similar size as on Linux and BSD. I also could fix the 'sleep' error.
I have replaced the newlisp-mingw.exe with the smaller one with the sleep fix on the usual http://newlisp.org/downloads/development/
We will have a new development release with an improved 'net-sessions' during the coming week.
Thanks for doing more testing. I am very encouraged now with the smaller size of the exe file and might consider to make MinGW the default for the Win32 distribution.
Lutz
I have replaced the newlisp-mingw.exe with the smaller one with the sleep fix on the usual http://newlisp.org/downloads/development/
We will have a new development release with an improved 'net-sessions' during the coming week.
Thanks for doing more testing. I am very encouraged now with the smaller size of the exe file and might consider to make MinGW the default for the Win32 distribution.
Lutz
Perfect.
With this new binary everything in the demoprogram works. I have replaced the (for) for a (sleep 1000). I have also put the final demoscript for newLisp with Win32 Named Pipes at my site http://www.gtk-server.org
NewLisp is the first non-basic language to support named pipes in Win32 with the GTK-server. The advantage is obvious: TCP ports will remain available for real network applications. Named Pipe support for Linux already worked.
Lutz, thanks again for your efforts. And I am happy to know that you are considering MinGW as your default compiler! I will use the MinGW port from now on myself, and let you know about difficulties or strange behaviour.
Thanks!
Peter
With this new binary everything in the demoprogram works. I have replaced the (for) for a (sleep 1000). I have also put the final demoscript for newLisp with Win32 Named Pipes at my site http://www.gtk-server.org
NewLisp is the first non-basic language to support named pipes in Win32 with the GTK-server. The advantage is obvious: TCP ports will remain available for real network applications. Named Pipe support for Linux already worked.
Lutz, thanks again for your efforts. And I am happy to know that you are considering MinGW as your default compiler! I will use the MinGW port from now on myself, and let you know about difficulties or strange behaviour.
Thanks!
Peter
Testing a little bit with the MinGw.exe, everything works so far.
I only see little performance differences:
I only see little performance differences:
Code: Select all
Borland:
(setq y 1)
1
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4094
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4125
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4094
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4109
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4172
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4109
>
MinGW:
> (setq y 1)
1
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4609
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4578
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4594
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4578
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4625
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4640
Hans-Peter
Just digging a bit around with the newLISP-versions, I take a look with the dependency-walker at them:
Both version's and the DLL gets:
Both version's and the DLL gets:
I have no idea for what it is good and if it is a problem.Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
MPR.DLL (18.08.2001 55808 Bytes)
Hans-Peter
Yes, that is correct, I was playing around with the optimization options, and settled on -O3 which gives me close to the same performance and a 165K executable, which is still smaller than the 198K before.
The benchmark I am running is a mixture of different tasks of aritmetik, call overhead, list manipulation and string manipulation.
I got UTF-8 going without a problem, but I am still working on the DLL with MinGW.
Lutz
ps: don't think that the MPR.DLL message is a problem, seems to be internal to some of the Win libraries. I guess you would get this message on any previous version too.
The benchmark I am running is a mixture of different tasks of aritmetik, call overhead, list manipulation and string manipulation.
I got UTF-8 going without a problem, but I am still working on the DLL with MinGW.
Lutz
ps: don't think that the MPR.DLL message is a problem, seems to be internal to some of the Win libraries. I guess you would get this message on any previous version too.
latest versions of newlisp.exe and newlisp.dll compiled with MinGW and based on v8.0.9 are in:
http://newlisp.org/downloads/development/MinGW/
makefiles for this will be released this week in 8.0.10
Lutz
http://newlisp.org/downloads/development/MinGW/
makefiles for this will be released this week in 8.0.10
Lutz
A quick test here in the office shows that most things are working. Performance is now identical with the BCC-version.
I found one problem with the DLL. Using my demo-app for neobook, it terminates the whole app when using the (Restart:run) function from the last demo-page. It close the app (and also the whole neobook IDE) without any message, when it comes back from a command sequence. I have to further investigate, when I am back home.
I found one problem with the DLL. Using my demo-app for neobook, it terminates the whole app when using the (Restart:run) function from the last demo-page. It close the app (and also the whole neobook IDE) without any message, when it comes back from a command sequence. I have to further investigate, when I am back home.
Hans-Peter
Hans-Peter,
looks like Steve (adamss3 on this board) has similar problems using the MinGW compiled DLL, he is working on it and it seems to be fixed, I will put an update of newlisp.dll later. This needs thorough testing !!!. So far odbc.lsp (stdcall conventions) and sqlite.lsp (cdecl call conventions) seem to work fine. And Steve has a whole lot of other stdcall stuff in test.
Lutz
looks like Steve (adamss3 on this board) has similar problems using the MinGW compiled DLL, he is working on it and it seems to be fixed, I will put an update of newlisp.dll later. This needs thorough testing !!!. So far odbc.lsp (stdcall conventions) and sqlite.lsp (cdecl call conventions) seem to work fine. And Steve has a whole lot of other stdcall stuff in test.
Lutz
Posted newlisp-8010.exe and newlisp-8010.dll in development/MinGW, this hopefully fixes HPW DLL restart problems in NeoBook. 8.0.10 also contains the mod to 'net-sessions' (requested by Norman) which now also reports client connections.
If HPW and Steve don't have any other issues I can make a 8.0.10 development release later this afternoon.
Lutz
If HPW and Steve don't have any other issues I can make a 8.0.10 development release later this afternoon.
Lutz