TCP/IP server suite

Started by Dmi, March 12, 2008, 05:43:43 AM

Previous topic - Next topic

Dmi

Recently found that frequently I need a tcp server in newlisp to serve simple data requests.

But net-select etc. is a low-level stuff which needs many workarounds in a real usage.



So, once I'v decide to made a such one. Here is it:

http://en.feautec.pp.ru/store/libs/doc/net-do.lsp.html">//http://en.feautec.pp.ru/store/libs/doc/net-do.lsp.html
WBR, Dmi

Lutz

#1
... also accessible via "Index: EnFeutec" on



http://www.newlisp.org/modules/">http://www.newlisp.org/modules/



All newlispdoc documented modules can be accessed directly or indirectly from here.

Dmi

#2
Wow! Cool!



BTW, you can set EnFeautec link directly to the module index:



http://en.feautec.pp.ru/store/libs/doc/index.html">//http://en.feautec.pp.ru/store/libs/doc/index.html
WBR, Dmi

Dmi

#3
A usage example:
    ; use "nc host 8080" to connect, ? to request connections and x to shutdown server
     (define (net-do-test)
      (net-do 8080 nil 1000
      ; accept
      (fn(conn)
        (println "accept: " conn)
        (net-send conn "hello!n"))
      ; receive
      (fn(conn , (buf ""))
        (println "receive: "conn)
        (net-receive conn 'buf 1000)
        (if
          (starts-with buf "?")
          (net-send conn (string net-do:lconn))
          (starts-with buf "x")
          (set 'net-do:exit-cond true))
        (net-send conn "bye!n")
        (net-do:close conn))
      ; cleanout
      (fn(conn) (println "closed: " conn))
      ; cycle
      nil
      ; idle
      (fn()(println "idle: " net-do:lconn))))
WBR, Dmi

Dmi

#4
The timeout is moved from (sleep) to (select), Now in micro-seconds.
WBR, Dmi

newdep

#5
Nice!.. a tcp broker at hand ;-)
-- (define? (Cornflakes))

Dmi

#6
Version 1.2

Some improvements,code cleanups and fixes.
WBR, Dmi

newdep

#7
I always wondered if it would not be nice to dump all the current net- functions

in more reduced functions with more options... But building this is ofcourse a

very nice option ;-)



My ideal IO broker would support "any" IO interface in newlisp..(hint hint..) ;-)
-- (define? (Cornflakes))