This commit is contained in:
Unknown
2013-05-07 23:43:09 -04:00
parent 9f0b4ae8c1
commit ffca9f3c2b
97 changed files with 7353 additions and 57 deletions

View File

@@ -0,0 +1,32 @@
// socket.go
package main
import (
"fmt"
"net"
"io"
)
func main() {
var (
host = "www.apache.org"
port = "80"
remote = host + ":" + port
msg string = "GET / \n"
data = make([]uint8, 4096)
read = true
count = 0
)
// create the socket
con, err := net.Dial("tcp", remote)
// send our message. an HTTP GET request in this case
io.WriteString(con, msg)
// read the response from the webserver
for read {
count, err = con.Read(data)
read = (err == nil)
fmt.Printf(string(data[0:count]))
}
con.Close()
}