socket implementation