TCP ports use lots

This commit is contained in:
Zack Scholl 2018-09-25 17:18:43 -07:00
parent ec5d45307a
commit 71fee31da0
2 changed files with 3 additions and 6 deletions

View File

@ -292,7 +292,6 @@ func receive(forceSend int, serverAddress string, tcpPorts []string, isLocal boo
dataChan <- message dataChan <- message
} }
} }
_ = <-finished
} else { } else {
log.Debugf("starting listening with tcp with %d connections", len(tcpConnections)) log.Debugf("starting listening with tcp with %d connections", len(tcpConnections))
// using TCP // using TCP
@ -324,8 +323,7 @@ func receive(forceSend int, serverAddress string, tcpPorts []string, isLocal boo
} }
_ = <-finished _ = <-finished
log.Debug("finished") log.Debug("telling sender i'm done")
c.WriteMessage(websocket.BinaryMessage, []byte("done")) c.WriteMessage(websocket.BinaryMessage, []byte("done"))
// we are finished // we are finished
transferTime = time.Since(startTime) transferTime = time.Since(startTime)

View File

@ -342,10 +342,9 @@ func send(forceSend int, serverAddress string, tcpPorts []string, isLocal bool,
return err return err
} }
if bytes.Equal(data.b, []byte("magic")) { if bytes.Equal(data.b, []byte("magic")) {
return break
} }
} }
} else { } else {
for i := range tcpConnections { for i := range tcpConnections {
go func(tcpConnection comm.Comm) { go func(tcpConnection comm.Comm) {
@ -355,7 +354,6 @@ func send(forceSend int, serverAddress string, tcpPorts []string, isLocal bool,
log.Error(data.err) log.Error(data.err)
return return
} }
bar.Add(data.bytesRead) bar.Add(data.bytesRead)
// write data to tcp connection // write data to tcp connection
_, err = tcpConnection.Write(data.b) _, err = tcpConnection.Write(data.b)
@ -383,6 +381,7 @@ func send(forceSend int, serverAddress string, tcpPorts []string, isLocal bool,
case 5: case 5:
transferTime := time.Since(startTransfer) transferTime := time.Since(startTransfer)
if !bytes.HasPrefix(message, []byte("hash:")) { if !bytes.HasPrefix(message, []byte("hash:")) {
log.Debugf("%s", message)
continue continue
} }
c.WriteMessage(websocket.BinaryMessage, fileHash) c.WriteMessage(websocket.BinaryMessage, fileHash)