buffer socket write using select