adapt to SocketChannels as well