Created
June 23, 2014 16:55
-
-
Save rickt/a797018cf97f2669110d to your computer and use it in GitHub Desktop.
example CLIENT code that connects to a TCP socket & sends GOB-encoded data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// use this with tcpgobserver.go | |
import ( | |
"encoding/gob" | |
"fmt" | |
"log" | |
"net" | |
) | |
type P struct { | |
M, N int64 | |
} | |
func main() { | |
fmt.Println("start client") | |
conn, err := net.Dial("tcp", "localhost:7743") | |
if err != nil { | |
log.Fatal("Connection error", err) | |
} | |
encoder := gob.NewEncoder(conn) | |
p := &P{8192, 4096} | |
encoder.Encode(p) | |
conn.Close() | |
fmt.Println("done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment