Why not accept the connection and then start the process
with the new connection in its initial set of file descriptors.
That's what inetd does.
> Both of these would be easy to do with syscall.Select and os.ForkExec
> if I could get access to the os.File from the Listener, but there
> doesn't seem to be a way to do that.
That's a known issue. I'm planning to fix it this week.
You can't just expose the *os.File because it is in
non-blocking mode and will probably make other users
fail. Instead I plan to add a File() *os.File method to
the various low-level network types that gives you a
different file (that is, a different fd) for the network
connection, that one opened in blocking mode as most
programs expect.
You'd have to do a conversion to the specific
type and then call the file method: l.(*net.TCPListener).File().
Russ
> That's a known issue. I'm planning to fix it this week.
> You can't just expose the *os.File because it is in
> non-blocking mode and will probably make other users
> fail. Instead I plan to add a File() *os.File method to
> the various low-level network types that gives you a
> different file (that is, a different fd) for the network
> connection, that one opened in blocking mode as most
> programs expect.
>
> You'd have to do a conversion to the specific
> type and then call the file method: l.(*net.TCPListener).File().
Or presumably something like
type FileInterface {
File() *os.File
}
f := l.(FileInterface).File()
Ian
I'm starting a potentially stateful process that can accept
connections and act as a point of communication. Also, it might want
to handle many concurrent open connections, and having that many
processes (say, ~40K) would be significantly slower. For example,
memcached.
inetd actually does both of these, depending on the setting of wait or
nowait. I'm interested in the "wait" behavior.
> That's a known issue. I'm planning to fix it this week.
Fantastic, then I'll just check again in a week. Thanks!
kr
This doesn't appear to be done yet, and I'd like to help out with a
patch. I have a couple of questions:
Is it sufficient to dup the fd, ensure the new fd is in blocking mode,
and then wrap it in an os.File?
Aside from net.TCPListener and net.UnixListener, are there other types
that should get this treatment? Such as net.TCPConn, net.UDPConn, and
net.UnixConn?
Should I open a ticket for this issue and put further discussion there?
kr
The issue is here:
http://code.google.com/p/go/issues/detail?id=918
I'm also interested in getting this fixed.
Regards
Albert