Adding socket reading code.