v / examples
Raw file
		
1import net
2import io
3
4fn main() {
5 // Make a new connection
6 mut conn := net.dial_tcp('google.com:80')?
7 defer {
8 conn.close() or {}
9 }
10
11 println(' peer: ${conn.peer_addr()?}')
12 println('local: ${conn.addr()?}')
13
14 // Simple http HEAD request for a file
15 conn.write_string('HEAD /index.html HTTP/1.0\r\n\r\n')?
16 // Read all the data that is waiting
17 result := io.read_all(reader: conn)?
18 // Cast to string and print result
19 println(result.bytestr())
20}