Move connection process into socket class.