Fixed missing return value

This prevents the thing from segfaulting
fixed printf packet len
added more error checking