Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Echo server in 10-years old Tcl (more?):

    socket -server acceptConnections 9999
    proc acceptConnections {fd clientaddr clientport} {
        fconfigure $fd -blocking 0
        fileevent $fd readable [list replyToClient $fd]
    }
    proc replyToClient fd {
        set s [read $fd]
        puts -nonewline $fd $s
        flush $fd
    }
    vwait forever
Note that this is a multiplexing non blocking server, exactly like Twisted / Tornado. All features built-in in the language. Tcl failed copying the obvious missing features from other languages. Other languages are failing copying the good things from Tcl.

p.s. note the poetry contained in the "vwait forever" statement ;) Our program is willing to run without stop until the end of the universe.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: