mirror of https://github.com/schollz/croc.git
try fix
This commit is contained in:
parent
0bd4a0ac75
commit
089d2bbe1a
|
@ -419,7 +419,7 @@ func connectToTCPServer(room string, address string) (com *comm.Comm, err error)
|
||||||
connection.SetReadDeadline(time.Now().Add(3 * time.Hour))
|
connection.SetReadDeadline(time.Now().Add(3 * time.Hour))
|
||||||
connection.SetDeadline(time.Now().Add(3 * time.Hour))
|
connection.SetDeadline(time.Now().Add(3 * time.Hour))
|
||||||
connection.SetWriteDeadline(time.Now().Add(3 * time.Hour))
|
connection.SetWriteDeadline(time.Now().Add(3 * time.Hour))
|
||||||
|
connection.SetNoDelay(true)
|
||||||
com = comm.New(connection)
|
com = comm.New(connection)
|
||||||
log.Debug("waiting for server contact")
|
log.Debug("waiting for server contact")
|
||||||
ok, err := com.Receive()
|
ok, err := com.Receive()
|
||||||
|
|
|
@ -420,6 +420,7 @@ func connectToTCPServer(room string, address string) (com *comm.Comm, err error)
|
||||||
connection.SetReadDeadline(time.Now().Add(3 * time.Hour))
|
connection.SetReadDeadline(time.Now().Add(3 * time.Hour))
|
||||||
connection.SetDeadline(time.Now().Add(3 * time.Hour))
|
connection.SetDeadline(time.Now().Add(3 * time.Hour))
|
||||||
connection.SetWriteDeadline(time.Now().Add(3 * time.Hour))
|
connection.SetWriteDeadline(time.Now().Add(3 * time.Hour))
|
||||||
|
connection.SetNoDelay(true)
|
||||||
|
|
||||||
com = comm.New(connection)
|
com = comm.New(connection)
|
||||||
ok, err := com.Receive()
|
ok, err := com.Receive()
|
||||||
|
|
|
@ -2,7 +2,6 @@ package tcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -168,18 +167,14 @@ func pipe(conn1 net.Conn, conn2 net.Conn) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
writer2.Write(b1)
|
writer2.Write(b1)
|
||||||
if bytes.Equal(b1, []byte("magic")) {
|
writer2.Flush()
|
||||||
writer2.Flush()
|
|
||||||
}
|
|
||||||
|
|
||||||
case b2 := <-chan2:
|
case b2 := <-chan2:
|
||||||
if b2 == nil {
|
if b2 == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
writer1.Write(b2)
|
writer1.Write(b2)
|
||||||
if bytes.Equal(b2, []byte("magic")) {
|
writer1.Flush()
|
||||||
writer1.Flush()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue