write sizeof(buf) length to write recv function return the length