0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

use netconn

This commit is contained in:
Zack Scholl 2018-09-26 10:46:36 -07:00
parent 420d2be271
commit fecc8d5897
2 changed files with 22 additions and 12 deletions

View file

@ -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()

View file

@ -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()