implement handshake prototype

What's `res`?