I don't think mysql_close() is calling shutdown() on the socket, I think the socket is being closed by the server because mysql_close() sends a QUIT message.