Very VERY dirty impl. of db connection + socket connection