# Copyright 2005 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ Basic ? IP # value: Host names Not sure yet what the right name service interface is. For now I'm using: http://www.opengroup.org/onlinepubs/009695399/functions/getaddrinfo.html as a guide - if you're reading this and have an opinion, please let me know. ? interp.waitAtTop(def i := > IP.getAddrInfo("localhost", null, null)); i # value: ? i # value: Trivial streams ? def ALL := EIO.getALL(); null ? def e := IP.getRemoteTCPEndpoint("127.0.0.1", "80") # value: ? def [ins, outs] := e.connect([].asMap()) > interp.waitAtTop(ins) > interp.waitAtTop(outs) ? [ins, outs] # value: [<-127.0.0.1:80, ->127.0.0.1:80] ? ins.available() # value: 0 ? outs.available() > 0 # value: true this is "GET / HTTP/1.0\r\n\r\n" ? outs.write([71, 69, 84, 32, 47, 32, 72, 84, 84, 80, 47, 49, 46, 48, 13, 10, 13, 10]) ? outs.flush() ? interp.waitAtTop(ins.whenAvailable(8, thunk { > print(ins.read(0, 17)) > })) this is "HTTP/1.1 200 OK\r\n" # stdout: [72, 84, 84, 80, 47, 49, 46, 49, 32, 50, 48, 48, 32, 79, 75, 13, 10] ? [ins.close(), outs.close()] # value: [true, true] Endpoint with hostname ? def e2 := IP.getRemoteTCPEndpoint("localhost", "80") # value: ? def [ins2, outs2] := e.connect([].asMap()) > interp.waitAtTop(ins2) > interp.waitAtTop(outs2) ? [ins2, outs2] # value: [<-127.0.0.1:80, ->127.0.0.1:80] ? [ins2.close(), outs2.close()] # value: [true, true]