kinda works better
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b932251092
commit
562b20cbb4
33
socketWIT.go
33
socketWIT.go
|
@ -55,7 +55,8 @@ func socketToWIT(myhostname string) {
|
|||
|
||||
log.Println("socket connected to", CONN_PROTO, CONN_HOST, CONN_PORT)
|
||||
|
||||
fmt.Fprintf(conn, myhostname + "\n")
|
||||
tmp, err := conn.Write([]byte(string(myhostname + "\n")))
|
||||
log.Println("conn.Write:", tmp, err)
|
||||
|
||||
connStdin, _ := conn.File()
|
||||
|
||||
|
@ -64,38 +65,26 @@ func socketToWIT(myhostname string) {
|
|||
// read in input from stdin
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
// read in the command to send to our server
|
||||
fmt.Print("Text to send: ")
|
||||
text, _ := reader.ReadString('\n')
|
||||
// send to socket
|
||||
fmt.Fprintf(conn, text + "\n")
|
||||
a, err := connStdin.Write([]byte(string(text + "\n")))
|
||||
|
||||
// send the command over the socket socket
|
||||
a, err := conn.Write([]byte(string(text + "\n")))
|
||||
|
||||
// a, err := connStdin.Write([]byte(string(text + "\n")))
|
||||
if (err != nil) {
|
||||
fmt.Println("SOCKET DIED with err=", err, a)
|
||||
return
|
||||
}
|
||||
// TODO: check the socket has died and exit here
|
||||
}
|
||||
/*
|
||||
// listen for reply
|
||||
|
||||
newreader := bufio.NewReader(newStdin)
|
||||
|
||||
for {
|
||||
message, err := newreader.ReadString('\n')
|
||||
fmt.Println("Message from server: ", message)
|
||||
if (err != nil) {
|
||||
fmt.Println("SOCKET DIED with err=", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func retrySocket() {
|
||||
for {
|
||||
log.Println("Sleep for 1 seconds, then try to establish connection to WIT")
|
||||
time.Sleep(1 * 1000 * 1000 * 1000)
|
||||
log.Println("Sleep for 3 seconds, then try to establish connection to WIT")
|
||||
time.Sleep(3 * 1000 * 1000 * 1000)
|
||||
|
||||
// for now, loop until I figure out what to actually do
|
||||
socketToWIT("librem15.lab.wit.com")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue