Making Samples executable. #!/usr/bin/env io and chmod a+x *.io
[io/quag.git] / addons / Socket / samples / WebRequest.io
blobb771b4a33c871d4599ed08e6f6f2e421d84d4a76
1 #!/usr/bin/env io
4 //DNSResolver addServerAddress("128.105.2.10")
6 ip := Host clone setName("www.yahoo.com") address
8 socket := Socket clone setHost(ip) setPort(80)
9 socket connect
11 if (socket error) then (
12 writeln(socket error)
13 ) else (
14 socket write("GET /\n\n")
16 response := ""
17 while(socket isOpen,
18 socket streamReadNextChunk
19 response = response .. (socket readBuffer)
22 writeln(response)
23 writeln("\nReceived ", response size, " bytes")