This is to avoid a weird bug in the previous glib iochannel implementation, where the socket was randomly being closed after about a minute run time. But it's also less code, so that's OK