Skip to content

Commit

Permalink
client takes host and port
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed May 29, 2023
1 parent 8919ebb commit e65b4ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion util/client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ module Main where

import Control.Concurrent.Async
import qualified Control.Exception as E
import Control.Monad
import qualified Data.ByteString.Char8 as C8
import Network.HTTP.Types
import Network.Run.TCP (runTCPClient) -- network-run
import System.Environment
import System.Exit

import Network.HTTP2.Client

serverName :: String
serverName = "127.0.0.1"

main :: IO ()
main = runTCPClient serverName "8080" $ runHTTP2Client serverName
main = do
args <- getArgs
when (length args /= 2) $ do
putStrLn "client <addr> <port>"
exitFailure
let [host,port] = args
runTCPClient serverName port $ runHTTP2Client host
where
cliconf host = ClientConfig "http" (C8.pack host) 20
runHTTP2Client host s = E.bracket (allocSimpleConfig s 4096)
Expand Down
3 changes: 2 additions & 1 deletion util/server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import qualified Data.ByteString.Char8 as C8
import Network.HPACK
import Network.HPACK.Token
import Network.HTTP.Types
import Network.HTTP2.Server
import Network.Run.TCP -- network-run
import System.Environment
import System.Exit

import Network.HTTP2.Server

main :: IO ()
main = do
args <- getArgs
Expand Down

0 comments on commit e65b4ae

Please sign in to comment.