handShake :: Peer -> ByteString -> String -> IO Handle
handShake (Peer ip port) infoHash peerid = do
  let hs = genHandShakeMsg infoHash peerid
  h <- connectTo ip (PortNumber (fromIntegral port))
  hSetBuffering h LineBuffering
  hPut h hs
  rlenBS <- hGet h (length (unpack hs))
  putStrLn $ "got handshake from peer: " ++ show rlenBS
  return h
handShake :: Peer -> ByteString -> String -> IO Handle
handShake (Peer ip port) infoHash peerid = do
  let hs = genHandShakeMsg infoHash peerid
  h <- connectTo ip (PortNumber (fromIntegral port))
  hSetBuffering h LineBuffering
  hPut h hs
  rlenBS <- hGet h (length (unpack hs))
  putStrLn $ "got handshake from peer: " ++ show rlenBS
  return h
handShake (Peer ip port) infoHash peerid = do
  let hs = genHandShakeMsg infoHash peerid
  h <- connectTo ip (PortNumber (fromIntegral port))
  hSetBuffering h LineBuffering
  hPut h hs
  rlenBS <- hGet h (length (unpack hs))
  putStrLn $ "got handshake from peer: " ++ show rlenBS
  return h