diff --git a/compilers/json/postalcodes.pir b/compilers/json/postalcodes.pir
index d047169..b4337dd 100755
a
|
b
|
|
27 | 27 | |
28 | 28 | postal = argv[1] |
29 | 29 | |
30 | | .local pmc sock |
31 | | .local string address, buf, json_result |
| 30 | .local pmc sock, address |
| 31 | .local string buf, json_result |
32 | 32 | json_result = '' |
33 | 33 | .local int ret |
34 | 34 | .local int len |
35 | 35 | |
36 | 36 | # create the socket handle |
37 | | socket sock, 2, 1, 0 |
| 37 | sock = new 'Socket' |
| 38 | sock.'socket'(2, 1, 0) |
38 | 39 | unless sock goto ERR |
39 | 40 | |
40 | 41 | # Pack a sockaddr_in structure with IP and port |
41 | | sockaddr address, 80, 'ws.geonames.org' |
42 | | connect ret, sock, address |
| 42 | address = sock.'sockaddr'('ws.geonames.org', 80) |
| 43 | sock.'connect'(address) |
43 | 44 | |
44 | 45 | .local string url |
45 | 46 | url = 'http://ws.geonames.org/postalCodeSearchJSON?maxRows=10&postalcode=' |
… |
… |
|
48 | 49 | $S0 = 'GET ' |
49 | 50 | $S0 .= url |
50 | 51 | $S0 .= " HTTP/1.0\nUser-agent: Parrot\n\n" |
51 | | send ret, sock, $S0 |
52 | | poll ret, sock, 1, 5, 0 |
| 52 | sock.'send'($S0) |
| 53 | #poll ret, sock, 1, 5, 0 |
53 | 54 | MORE: |
54 | | recv ret, sock, buf |
55 | | if ret < 0 goto END |
| 55 | buf = sock.'recv'() |
| 56 | ret = length buf |
| 57 | if ret <= 0 goto END |
56 | 58 | json_result .= buf |
57 | 59 | goto MORE |
58 | 60 | ERR: |