socket length was not calculated properly