net: move bind back to sock.go

It was left in netFD.connect() by an oversight (as the name
implies, bind has no business being in connect). As a result
of this change and by only calling netFD.connect() when ra
isn't nil it becomes simpler with less code duplication.

Additionally, if netFD.connect() fails, set sysfd to -1 to
avoid finalizers (e.g. on windows) calling shutdown on a
closed and possibly reopened socket that just happened to
share the same descriptor.

R=golang-dev, rsc1, rsc
CC=golang-dev
https://golang.org/cl/4328043
diff --git a/src/pkg/net/fd.go b/src/pkg/net/fd.go
index 3e87800..cd1a21d 100644
--- a/src/pkg/net/fd.go
+++ b/src/pkg/net/fd.go
@@ -303,26 +303,18 @@
 	fd.sysfile = os.NewFile(fd.sysfd, fd.net+":"+ls+"->"+rs)
 }
 
-func (fd *netFD) connect(la, ra syscall.Sockaddr) (err os.Error) {
-	if la != nil {
-		e := syscall.Bind(fd.sysfd, la)
-		if e != 0 {
-			return os.Errno(e)
+func (fd *netFD) connect(ra syscall.Sockaddr) (err os.Error) {
+	e := syscall.Connect(fd.sysfd, ra)
+	if e == syscall.EINPROGRESS {
+		var errno int
+		pollserver.WaitWrite(fd)
+		e, errno = syscall.GetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_ERROR)
+		if errno != 0 {
+			return os.NewSyscallError("getsockopt", errno)
 		}
 	}
-	if ra != nil {
-		e := syscall.Connect(fd.sysfd, ra)
-		if e == syscall.EINPROGRESS {
-			var errno int
-			pollserver.WaitWrite(fd)
-			e, errno = syscall.GetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_ERROR)
-			if errno != 0 {
-				return os.NewSyscallError("getsockopt", errno)
-			}
-		}
-		if e != 0 {
-			return os.Errno(e)
-		}
+	if e != 0 {
+		return os.Errno(e)
 	}
 	return nil
 }