mirror of
https://github.com/golang/go.git
synced 2025-11-10 05:31:03 +00:00
net: implement non-blocking connect
Refactored bind/connect from sock.go into netFD.connect(), as a consequence newFD() doesn't accept laddr/raddr anymore, and expects an (optional) call to netFD.connect() followed by a call to netFD.setAddr(). Windows code is updated, but still uses blocking connect, since otherwise it needs support for ConnectEx syscall. R=brainman, rsc CC=golang-dev https://golang.org/cl/4303060
This commit is contained in:
parent
98828f033a
commit
2f45f72dce
4 changed files with 83 additions and 41 deletions
|
|
@ -9,7 +9,7 @@ import (
|
|||
"syscall"
|
||||
)
|
||||
|
||||
func newFileFD(f *os.File) (*netFD, os.Error) {
|
||||
func newFileFD(f *os.File) (nfd *netFD, err os.Error) {
|
||||
fd, errno := syscall.Dup(f.Fd())
|
||||
if errno != 0 {
|
||||
return nil, os.NewSyscallError("dup", errno)
|
||||
|
|
@ -50,7 +50,11 @@ func newFileFD(f *os.File) (*netFD, os.Error) {
|
|||
sa, _ = syscall.Getpeername(fd)
|
||||
raddr := toAddr(sa)
|
||||
|
||||
return newFD(fd, 0, proto, laddr.Network(), laddr, raddr)
|
||||
if nfd, err = newFD(fd, 0, proto, laddr.Network()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nfd.setAddr(laddr, raddr)
|
||||
return nfd, nil
|
||||
}
|
||||
|
||||
// FileConn returns a copy of the network connection corresponding to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue