added shutdown before close() socket calls