if tc, ok := nc.(*net.TCPConn); ok {
tc.SetLinger(0)
}
- c := newConnection()
- c.conn = nc
- c.rw = nc
+ c := cl.newConnection(nc)
c.Discovery = peerSourceIncoming
c.uTP = utp
err := cl.runReceivedConn(c)
// Performs initiator handshakes and returns a connection. Returns nil
// *connection if no connection for valid reasons.
func (cl *Client) handshakesConnection(nc net.Conn, t *Torrent, encrypted, utp bool) (c *connection, err error) {
- c = newConnection()
- c.conn = nc
- c.rw = nc
+ c = cl.newConnection(nc)
c.encrypted = encrypted
c.uTP = utp
err = nc.SetDeadline(time.Now().Add(handshakesTimeout))