diff options
Diffstat (limited to 'stdlib/source/lux/world/net/udp.jvm.lux')
-rw-r--r-- | stdlib/source/lux/world/net/udp.jvm.lux | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/stdlib/source/lux/world/net/udp.jvm.lux b/stdlib/source/lux/world/net/udp.jvm.lux index 139ed4f49..3bb94e112 100644 --- a/stdlib/source/lux/world/net/udp.jvm.lux +++ b/stdlib/source/lux/world/net/udp.jvm.lux @@ -14,24 +14,24 @@ [host]) [//]) -(host;import java.lang.AutoCloseable +(host;import java/lang/AutoCloseable (close [] #io #try void)) -(host;import java.io.Flushable +(host;import java/io/Flushable (flush [] #io #try void)) -(host;import java.net.InetAddress +(host;import java/net/InetAddress (#static getAllByName [String] #io #try (Array InetAddress)) (getHostAddress [] String)) -(host;import java.net.DatagramPacket +(host;import java/net/DatagramPacket (new #as new|send [(Array byte) int int InetAddress int]) (new #as new|receive [(Array byte) int int]) (getAddress [] InetAddress) (getPort [] int) (getLength [] int)) -(host;import java.net.DatagramSocket +(host;import java/net/DatagramSocket (new #as new|client [] #io #try) (new #as new|server [int] #io #try) (receive [DatagramPacket] #io #try void) @@ -47,7 +47,7 @@ (def: (resolve address) (-> //;Address (io;IO (e;Error InetAddress))) (do (e;ErrorT io;Monad<IO>) - [addresses (InetAddress.getAllByName [address])] + [addresses (InetAddress::getAllByName [address])] (: (io;IO (e;Error InetAddress)) (case (array;size addresses) +0 (io;io (ex;throw Cannot-Resolve-Address address)) @@ -60,14 +60,14 @@ (def: #export (read data offset length self) (-> Blob Nat Nat UDP (T;Task [Nat //;Address //;Port])) (let [(^open) (@repr self) - packet (DatagramPacket.new|receive [data (nat-to-int offset) (nat-to-int length)])] + packet (DatagramPacket::new|receive [data (nat-to-int offset) (nat-to-int length)])] (P;future (do (e;ErrorT io;Monad<IO>) - [_ (DatagramSocket.receive [packet] socket) - #let [bytes-read (int-to-nat (DatagramPacket.getLength [] packet))]] + [_ (DatagramSocket::receive [packet] socket) + #let [bytes-read (int-to-nat (DatagramPacket::getLength [] packet))]] (wrap [bytes-read - (|> packet (DatagramPacket.getAddress []) (InetAddress.getHostAddress [])) - (int-to-nat (DatagramPacket.getPort [] packet))]))))) + (|> packet (DatagramPacket::getAddress []) (InetAddress::getHostAddress [])) + (int-to-nat (DatagramPacket::getPort [] packet))]))))) (def: #export (write address port data offset length self) (-> //;Address //;Port Blob Nat Nat UDP (T;Task Unit)) @@ -75,26 +75,26 @@ (do (e;ErrorT io;Monad<IO>) [address (resolve address) #let [(^open) (@repr self)]] - (DatagramSocket.send (DatagramPacket.new|send [data (nat-to-int offset) (nat-to-int length) address (nat-to-int port)]) - socket)))) + (DatagramSocket::send (DatagramPacket::new|send [data (nat-to-int offset) (nat-to-int length) address (nat-to-int port)]) + socket)))) (def: #export (close self) (-> UDP (T;Task Unit)) (let [(^open) (@repr self)] (P;future - (AutoCloseable.close [] socket)))) + (AutoCloseable::close [] socket)))) (def: #export (client _) (-> Unit (T;Task UDP)) (P;future (do (e;ErrorT io;Monad<IO>) - [socket (DatagramSocket.new|client [])] + [socket (DatagramSocket::new|client [])] (wrap (@opaque (#socket socket)))))) (def: #export (server port) (-> //;Port (T;Task UDP)) (P;future (do (e;ErrorT io;Monad<IO>) - [socket (DatagramSocket.new|server [(nat-to-int port)])] + [socket (DatagramSocket::new|server [(nat-to-int port)])] (wrap (@opaque (#socket socket)))))) ) |