Handle more events in callback,wait for socket to close