dnssecsocket/example-channel-goroutine/client.go

40 lines
769 B
Go
Raw Permalink Normal View History

package main
import "fmt"
import "net"
import "os"
import "log"
import "strconv"
// import "io"
// import "encoding/csv"
// import "flag"
import "github.com/golang/protobuf/proto"
import pb "git.wit.com/wit/witProtobuf"
func main() {
msg := pb.CreateSampleEvent()
msg.Name = "from dnssecsockettest()"
data, err := proto.Marshal(msg)
if (err != nil) {
log.Printf("something fucked up happened")
}
sendDataToDest(data)
}
func sendDataToDest(data []byte) {
conn, err := net.Dial("tcp", "localhost:8080")
if err != nil {
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
return
}
n, err := conn.Write(data)
if err != nil {
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
return
}
fmt.Println("Sent " + strconv.Itoa(n) + " bytes")
}