DialTimeout vs DialTCP

已查看 54 次
跳至第一个未读帖子

Albert Strasheim

未读,
2012年2月21日 06:51:172012/2/21
收件人 golang-dev
Hello all

We've run into an interesting issue using the Dial APIs: We want to
use DialTCP because we want to bind to a specific outgoing interface
by specifying laddr, but we also want to dial with a timeout because
the remote end might be down. There doesn't seem to be any way to do
this at present.

Maybe all the Dial<Proto> functions could also take a timeout? Or
maybe the distinction between Dial and DialTimeout actually needs to
go away and all Dials should have a timeout?

Thoughts?

Regards

Albert

Russ Cox

未读,
2012年2月21日 14:10:502012/2/21
收件人 Albert Strasheim、golang-dev
I think this might have to wait until after Go 1.
You can work around the problem by dialing in a
goroutine and using select to choose between the
dial finishing and a timer firing.

Russ

回复全部
回复作者
转发
0 个新帖子