'timer issue?

Started by newdep, July 31, 2006, 04:26:52 AM

Previous topic - Next topic

newdep

Hi Lutz,



There is someting odd with the behaviour of 'timer.

(I thought it was my OS/2 port...but its not..)





The 'timer example (sockets and timer) from the 8.9.1 manual does not work

on linux or OS/2 or WinXP..

(It simple does not return the 'timeout' text keeps in a loop...)





The strange thing is though... when I execute FIRST the timer routine and Then

the socket-init it all works on OS/2, but this does not work on Linux nor on WinXP..



What could be the problem with timer..?





This does not work on any system ->



(define (interrupt)

    (set 'timeout true))

       

(set 'listen (net-listen 30001))

(set 'socket (net-accept listen))

       

(timer 'interrupt 10)

; or specifying the function directly

(timer (fn () (set 'timeout true)) 10)

       

(until (or timeout done)

    (if (net-select socket "read" 100000)

        (begin

            (read-buffer socket 'buffer 1024)

            (set 'done true)))

)

                                                                               

(if timeout

    (println "timeout")

    (println buffer))

                                                                             

(exit)







But this works on OS/2 (not on Linux or WinXP) ->





(define (interrupt) (set 'timeout true))

(timer 'interrupt 10.0)



(set 'listen (net-listen 30001))

(set 'socket (net-accept listen))

     

(until (or timeout done)

    (if (net-select socket "read" 100000)

        (begin

            (read-buffer socket 'buffer 1024)

            (set 'done true)))

)

                                                                               

(if timeout (println "timeout") (println buffer))

                                                                             

(exit)





Regards, Norman
-- (define? (Cornflakes))

Lutz

#1
In the first example the timer is started after the connection is accepted. In the second example the timer is started before listening and accepting.



In either case it works for me on OS X 10.4 and FreeBSD 4.9 (don't have other OSs available at this moment).



What are you doing on the second computer? In either case you have to at least make a connection with (net-connect "host" 30001). You can do it on "localhost" on the same machine in a diffferent terminal window.



net-accept is a blocking function, so in the first example the timer will not start until an incoming connection is accepted. What is it you are doing on the second computer?



Lutz

newdep

#2
I had it completly at the wrong end!



Its working fine here.. on WinXP Linux and OS/2 ;-)



Thanks..
-- (define? (Cornflakes))