Ported the socket code to use asynchat.