mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
use netconn
This commit is contained in:
parent
420d2be271
commit
fecc8d5897
2 changed files with 22 additions and 12 deletions
|
@ -407,11 +407,17 @@ func receive(forceSend int, serverAddress string, tcpPorts []string, isLocal boo
|
||||||
|
|
||||||
func connectToTCPServer(room string, address string) (com *comm.Comm, err error) {
|
func connectToTCPServer(room string, address string) (com *comm.Comm, err error) {
|
||||||
log.Debugf("recipient connecting to %s", address)
|
log.Debugf("recipient connecting to %s", address)
|
||||||
rAddr, err := net.ResolveTCPAddr("tcp", address)
|
// rAddr, err := net.ResolveTCPAddr("tcp", address)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
connection, err := net.DialTCP("tcp", nil, rAddr)
|
// connection, err := net.DialTCP("tcp", nil, rAddr)
|
||||||
|
// if err != nil {
|
||||||
|
// err = errors.Wrap(err, "bad connection to tcp")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// connection.SetNoDelay(true)
|
||||||
|
connection, err := net.Dial("tcp", address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, "bad connection to tcp")
|
err = errors.Wrap(err, "bad connection to tcp")
|
||||||
return
|
return
|
||||||
|
@ -419,7 +425,6 @@ 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()
|
||||||
|
|
|
@ -408,11 +408,17 @@ func send(forceSend int, serverAddress string, tcpPorts []string, isLocal bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectToTCPServer(room string, address string) (com *comm.Comm, err error) {
|
func connectToTCPServer(room string, address string) (com *comm.Comm, err error) {
|
||||||
rAddr, err := net.ResolveTCPAddr("tcp", address)
|
// rAddr, err := net.ResolveTCPAddr("tcp", address)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
connection, err := net.DialTCP("tcp", nil, rAddr)
|
// connection, err := net.DialTCP("tcp", nil, rAddr)
|
||||||
|
// if err != nil {
|
||||||
|
// err = errors.Wrap(err, "bad connection to tcp")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// connection.SetNoDelay(true)
|
||||||
|
connection, err := net.Dial("tcp", address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, "bad connection to tcp")
|
err = errors.Wrap(err, "bad connection to tcp")
|
||||||
return
|
return
|
||||||
|
@ -420,7 +426,6 @@ 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()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue