

Golang custom transports and timeouts - ovokinder
http://biasedbit.com/blog/golang-custom-transports/

======
tptacek
I had a similar (though unrelated) problem early on with Golang writing a port
scanner, which forced me to hoist my own event loop (build around an explicit
select call) into my program: timeout or not, I needed _lots and lots_ of OS
file descriptors, and by relying on Golang's own event loop to close stale
ones on timeouts, I'd invariably run out.

~~~
sebcat
> I needed lots and lots of OS file descriptors

Why?

I ask because I wrote a port scanner professionally once, and I got away with
using one fd for network I/O. I can only think of one case where you end up
using a lot of fds and that is if you're using TCP sockets and connect(2)
where you'd end up with one fd/tested port, and that's not good.

~~~
tptacek
It had to work unprivileged in userland.

------
jbox
If you're going across the network, a slow timeout is often trickier than an
explicit failure.

I wrote about handling this in Python: [http://www.mobify.com/blog/http-
requests-are-hard/](http://www.mobify.com/blog/http-requests-are-hard/)

