Use the socket factory :). Some other minor change.