callback functions in socket call