haskell - Warp: Binding to Unix Domain Sockets -
the example code listed here shows how make warp listen on specific hosts.
furtheremore, this post shows basics on how use unix domain sockets in haskell.
how can combine 2 approaches in order make warp listen on (i.e. bind to) specific unix domain socket (say, warp.sock)?
note: question intentionally shows no research effort answered q&a-style.
you can use runsettingssocket af_unix socket:
{-# language overloadedstrings #-} import network.wai (responselbs) import network.wai.handler.warp import network.socket import network.http.types (status200) import network.http.types.header (hcontenttype) main = let port = 3000 -- open socket sock <- socket af_unix stream 0 bind sock $ sockaddrunix "warp.sock" listen sock maxlistenqueue -- run server let settings = defaultsettings { settingsport = port } runsettingssocket settings sock app -- cleanup: close socket close sock app req f = f $ responselbs status200 [(hcontenttype, "text/plain")] "hello world!" note work on unixoid platforms.
Comments
Post a Comment