try to reconnect when server is not yet started

Related #106
This commit is contained in:
Gokcehan committed 2018-07-26 21:58:09 +03:00
1 parent 40002a7752
commit 7dbb61f295
1 file changed
+7 -2
+7 -2
View File
@@ -8,6 +8,7 @@ import (
"net"
"os"
"strings"
"time"
"github.com/nsf/termbox-go"
)
@@ -53,10 +54,14 @@ func readExpr() <-chan expr {
ch := make(chan expr)
go func() {
duration := 1 * time.Second
c, err := net.Dial(gSocketProt, gSocketPath)
if err != nil {
for err != nil {
log.Printf(fmt.Sprintf("connecting server: %s", err))
return
c, err = net.Dial(gSocketProt, gSocketPath)
time.Sleep(duration)
duration *= 2
}
fmt.Fprintf(c, "conn %d\n", gClientID)