From bc896abb3408fc502bb02e62295aa3585bf2a56a Mon Sep 17 00:00:00 2001 From: Lachlan O'Dea Date: Sun, 14 Mar 2021 00:16:32 +1100 Subject: [PATCH] Update socket docs for latest API. --- docs/essentials/sockets.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/essentials/sockets.md b/docs/essentials/sockets.md index 868bc91d..966194e8 100644 --- a/docs/essentials/sockets.md +++ b/docs/essentials/sockets.md @@ -23,7 +23,8 @@ Creating a server socket: val server = AsynchronousServerSocketChannel() .mapM { socket => for { - _ <- SocketAddress.inetSocketAddress("127.0.0.1", 1337) >>= socket.bind + sockAddr <- InetSocketAddress.hostNameResolved("127.0.0.1", 1337) + _ <- socket.bindTo(sockAddr) _ <- socket.accept.preallocate.flatMap(_.use(channel => doWork(channel).catchAll(ex => putStrLn(ex.getMessage))).fork).forever.fork } yield () }.useForever @@ -46,8 +47,7 @@ Creating a client socket: val clientM: Managed[Exception, AsynchronousSocketChannel] = AsynchronousSocketChannel() .mapM { client => for { - host <- InetAddress.localHost - address <- SocketAddress.inetSocketAddress(host, 2552) + address <- InetSocketAddress.localHost(2552) _ <- client.connect(address) } yield client }