Updated Socket Code