Py3 compatibility: convert sock binary and strings