summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-01-23 18:20:21 -0500
committerjoe <joe@jerkface.net>2017-01-23 18:20:21 -0500
commit6a2506745dd06ad0849a1b0d440ad9751a69cf81 (patch)
tree4247dab403788c344091858ce72c06ae4b042983 /examples
parent9d1dad4af93598f403dae2d323539c60073f892d (diff)
New command "pid" to tell server's process id.
Diffstat (limited to 'examples')
-rw-r--r--examples/dhtd.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 19b45acb..4afceb50 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -24,6 +24,7 @@ import System.IO.Error
24import Text.PrettyPrint.HughesPJClass 24import Text.PrettyPrint.HughesPJClass
25import Text.Printf 25import Text.Printf
26import Control.Monad.Reader.Class 26import Control.Monad.Reader.Class
27import System.Posix.Process (getProcessID)
27 28
28import Network.BitTorrent.Address 29import Network.BitTorrent.Address
29import Network.BitTorrent.DHT 30import Network.BitTorrent.DHT
@@ -153,12 +154,16 @@ clientSession st signalQuit sock n h = do
153 return $ do 154 return $ do
154 hPutClient h $ showReport r 155 hPutClient h $ showReport r
155 156
156 ("peers ", s) -> cmd $ do 157 ("peers", s) -> cmd $ do
157 let ih = fromString s 158 let ih = fromString s
158 ps <- allPeers ih 159 ps <- allPeers ih
159 return $ do 160 return $ do
160 hPutClient h $ showReport $ map (((,) "") . show . pPrint) ps 161 hPutClient h $ showReport $ map (((,) "") . show . pPrint) ps
161 162
163 ("pid", _) -> cmd $ return $ do
164 pid <- getProcessID
165 hPutClient h (show pid)
166
162 _ -> cmd0 $ hPutClient h "error." 167 _ -> cmd0 $ hPutClient h "error."
163 168
164main :: IO () 169main :: IO ()