DialTimeout vs DialTCP

54 views
Skip to first unread message

Albert Strasheim

unread,
Feb 21, 2012, 6:51:17 AM2/21/12
to 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

unread,
Feb 21, 2012, 2:10:50 PM2/21/12
to 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

Reply all
Reply to author
Forward
0 new messages